mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-06 21:57:57 +02:00
fix: improve error handling when users conntect
This commit is contained in:
@@ -9,6 +9,7 @@ import * as express from "express";
|
|||||||
import config from "../../config";
|
import config from "../../config";
|
||||||
import UserModel from "../database/users/users.model";
|
import UserModel from "../database/users/users.model";
|
||||||
import { IUserDocument } from "../database/users/users.types";
|
import { IUserDocument } from "../database/users/users.types";
|
||||||
|
import AnonymousError from "../AnonymousError";
|
||||||
|
|
||||||
export function ensureAuthenticated(
|
export function ensureAuthenticated(
|
||||||
req: express.Request,
|
req: express.Request,
|
||||||
@@ -52,6 +53,11 @@ const verify = async (
|
|||||||
await user.save();
|
await user.save();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
throw new AnonymousError("unable_to_connect_user", {
|
||||||
|
httpStatus: 500,
|
||||||
|
object: profile,
|
||||||
|
cause: error as Error,
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
done(null, {
|
done(null, {
|
||||||
username: profile.username,
|
username: profile.username,
|
||||||
|
|||||||
Reference in New Issue
Block a user