Compare commits
2 Commits
154c763719
...
7b4e89555e
Author | SHA1 | Date | |
---|---|---|---|
7b4e89555e | |||
1e37186247 |
@ -19,7 +19,6 @@ const authchecker = async (action: Action, permissions: string[] | string) => {
|
||||
} else {
|
||||
required_permissions = permissions
|
||||
}
|
||||
console.log(required_permissions);
|
||||
|
||||
let jwtPayload = undefined
|
||||
try {
|
||||
@ -27,7 +26,6 @@ const authchecker = async (action: Action, permissions: string[] | string) => {
|
||||
jwtPayload = <any>jwt.verify(provided_token, config.jwt_secret);
|
||||
jwtPayload = jwtPayload["userdetails"];
|
||||
} catch (error) {
|
||||
console.log(action.request.headers["authorization"]);
|
||||
jwtPayload = await refresh(action);
|
||||
}
|
||||
|
||||
@ -41,7 +39,6 @@ const authchecker = async (action: Action, permissions: string[] | string) => {
|
||||
for (let required_permission of required_permissions) {
|
||||
if (!(jwtPayload["permissions"].includes(required_permission))) { return false; }
|
||||
}
|
||||
console.log("success");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,9 +52,6 @@ const refresh = async (action: Action) => {
|
||||
refresh_token = cookie.parse(action.request.headers["cookie"])["lfk_backend__refresh_token"];
|
||||
}
|
||||
catch {
|
||||
console.log(action.request.headers["cookie"])
|
||||
console.log("cookie fail here")
|
||||
console.log(cookie.parse(action.request.headers["cookie"]))
|
||||
throw new IllegalJWTError();
|
||||
}
|
||||
|
||||
@ -65,8 +59,6 @@ const refresh = async (action: Action) => {
|
||||
try {
|
||||
jwtPayload = <any>jwt.verify(refresh_token, config.jwt_secret);
|
||||
} catch (error) {
|
||||
console.log(refresh_token);
|
||||
console.log("jwt fail")
|
||||
throw new IllegalJWTError();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ export class HandleLogout {
|
||||
*/
|
||||
public async logout(): Promise<Logout> {
|
||||
let logout: Logout = new Logout();
|
||||
console.log(this.token)
|
||||
if (!this.token || this.token === undefined) {
|
||||
throw new JwtNotProvidedError()
|
||||
}
|
||||
@ -32,14 +33,17 @@ export class HandleLogout {
|
||||
try {
|
||||
decoded = jsonwebtoken.verify(this.token, config.jwt_secret)
|
||||
} catch (error) {
|
||||
console.log("decoding error")
|
||||
throw new IllegalJWTError()
|
||||
}
|
||||
logout.timestamp = Math.floor(Date.now() / 1000)
|
||||
let found_user: User = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["id"] });
|
||||
if (!found_user) {
|
||||
console.log("user error")
|
||||
throw new UserNotFoundError()
|
||||
}
|
||||
if (found_user.refreshTokenCount !== decoded["refreshTokenCount"]) {
|
||||
console.log("invalid rtc")
|
||||
throw new RefreshTokenCountInvalidError()
|
||||
}
|
||||
found_user.refreshTokenCount++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user