|
|
@ -4,6 +4,8 @@ import * as yaml from "js-yaml";
|
|
|
|
import {Op} from "sequelize";
|
|
|
|
import {Op} from "sequelize";
|
|
|
|
import dataaccess from "../lib/dataAccess";
|
|
|
|
import dataaccess from "../lib/dataAccess";
|
|
|
|
import {NotLoggedInGqlError, PostNotFoundGqlError} from "../lib/errors/graphqlErrors";
|
|
|
|
import {NotLoggedInGqlError, PostNotFoundGqlError} from "../lib/errors/graphqlErrors";
|
|
|
|
|
|
|
|
import {InvalidLoginError} from "../lib/errors/InvalidLoginError";
|
|
|
|
|
|
|
|
import {UserNotFoundError} from "../lib/errors/UserNotFoundError";
|
|
|
|
import globals from "../lib/globals";
|
|
|
|
import globals from "../lib/globals";
|
|
|
|
import {InternalEvents} from "../lib/InternalEvents";
|
|
|
|
import {InternalEvents} from "../lib/InternalEvents";
|
|
|
|
import * as models from "../lib/models";
|
|
|
|
import * as models from "../lib/models";
|
|
|
@ -151,10 +153,15 @@ export function resolver(req: any, res: any): any {
|
|
|
|
if (email && passwordHash) {
|
|
|
|
if (email && passwordHash) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const user = await dataaccess.getUserByLogin(email, passwordHash);
|
|
|
|
const user = await dataaccess.getUserByLogin(email, passwordHash);
|
|
|
|
return {
|
|
|
|
if (!user) {
|
|
|
|
expires: Number(user.authExpire),
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
value: user.token(),
|
|
|
|
return new InvalidLoginError(email);
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
expires: Number(user.authExpire),
|
|
|
|
|
|
|
|
value: user.token(),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
res.status(status.BAD_REQUEST);
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|
return err.graphqlError ?? new GraphQLError(err.message);
|
|
|
|