mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Update redis package.
This commit is contained in:
parent
6291654748
commit
7f1f3b685a
8 changed files with 26 additions and 29 deletions
|
|
@ -52,17 +52,18 @@ export default async (
|
|||
const user = await getUserByUsername(username, { includePassword: true });
|
||||
|
||||
if (user && checkPassword(password, user.password)) {
|
||||
if (redis.enabled) {
|
||||
if (redis) {
|
||||
const token = await setAuthKey(user);
|
||||
|
||||
return ok(res, { token, user });
|
||||
}
|
||||
|
||||
const token = createSecureToken({ userId: user.id }, secret());
|
||||
const { id, username, role, createdAt } = user;
|
||||
|
||||
return ok(res, {
|
||||
token,
|
||||
user: { id: user.id, username: user.username, role: user.role, createdAt: user.createdAt },
|
||||
user: { id, username, role, createdAt },
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
await useAuth(req, res);
|
||||
|
||||
if (req.method === 'POST') {
|
||||
if (redis.enabled) {
|
||||
if (redis) {
|
||||
await redis.del(getAuthToken(req));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { setAuthKey } from 'lib/auth';
|
|||
export default async (req: NextApiRequestAuth, res: NextApiResponse) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
if (redis.enabled && req.auth.user) {
|
||||
if (redis && req.auth.user) {
|
||||
const token = await setAuthKey(req.auth.user, 86400);
|
||||
|
||||
return ok(res, { user: req.auth.user, token });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue