Auth for everything (and everything auth) #6 #35

Merged
philipp merged 39 commits from feature/6-api_auth into dev 2020-12-18 21:53:18 +00:00
3 changed files with 4 additions and 4 deletions
Showing only changes of commit 1d54fb085b - Show all commits

View File

@ -43,7 +43,7 @@ const authchecker = async (action: Action, permissions: string[] | string) => {
const refresh = async (action: Action) => { const refresh = async (action: Action) => {
let refresh_token = undefined; let refresh_token = undefined;
try { try {
cookie.parse(action.request.headers["cookie"])["lfk_backend__refresh_token"]; refresh_token = cookie.parse(action.request.headers["cookie"])["lfk_backend__refresh_token"];
} }
catch { catch {
throw new IllegalJWTError(); throw new IllegalJWTError();

View File

@ -23,11 +23,11 @@ export class HandleLogout {
throw new IllegalJWTError() throw new IllegalJWTError()
} }
logout.timestamp = Math.floor(Date.now() / 1000) logout.timestamp = Math.floor(Date.now() / 1000)
let found_user: User = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["userid"] }); let found_user: User = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["id"] });
if (!found_user) { if (!found_user) {
throw new UserNotFoundError() throw new UserNotFoundError()
} }
if (found_user.refreshTokenCount !== decoded["refreshtokencount"]) { if (found_user.refreshTokenCount !== decoded["refreshTokenCount"]) {
throw new RefreshTokenCountInvalidError() throw new RefreshTokenCountInvalidError()
} }
found_user.refreshTokenCount++; found_user.refreshTokenCount++;

View File

@ -27,7 +27,7 @@ export class RefreshAuth {
if (!found_user) { if (!found_user) {
throw new UserNotFoundError() throw new UserNotFoundError()
} }
if (found_user.refreshTokenCount !== decoded["refreshtokencount"]) { if (found_user.refreshTokenCount !== decoded["refreshTokenCount"]) {
throw new RefreshTokenCountInvalidError() throw new RefreshTokenCountInvalidError()
} }
//Create the auth token //Create the auth token