Free and Open-source video streaming suite. https://miracle-tv.live
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

14 lines
616 B

import { MutationResolvers } from "miracle-tv/types/graphql";
import { ResolverContext } from "miracle-tv/types/resolver";
import { head } from "ramda";
import { InputErrorLogin } from "miracle-tv/graphql/errors/auth";
export const signInMutation: MutationResolvers<ResolverContext>["signIn"] =
async (_, { input: { username, password } }, { db: { users, sessions } }) => {
const userList = await users.getUsers({ username });
const user = head(userList);
if (user?.password === `salted+${password}`) {
return await sessions.createSession(user?.id!);
}
throw new InputErrorLogin();
};