refactor: refactored a few types around users and passwordless tokens in auth module
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
import * as O from 'fp-ts/Option';
|
||||
import { User } from './user.model';
|
||||
import { ProviderAccount } from '../types/ProviderAccount';
|
||||
import { AuthUser } from 'src/types/AuthUser';
|
||||
|
||||
@Injectable()
|
||||
export class UserService {
|
||||
@@ -11,7 +8,7 @@ export class UserService {
|
||||
|
||||
async findUserByEmail(email: string) {
|
||||
try {
|
||||
const user: AuthUser = await this.prisma.user.findUniqueOrThrow({
|
||||
const user = await this.prisma.user.findUniqueOrThrow({
|
||||
where: {
|
||||
email: email,
|
||||
},
|
||||
@@ -24,7 +21,7 @@ export class UserService {
|
||||
|
||||
async findUserById(userUid: string) {
|
||||
try {
|
||||
const user: AuthUser = await this.prisma.user.findUniqueOrThrow({
|
||||
const user = await this.prisma.user.findUniqueOrThrow({
|
||||
where: {
|
||||
id: userUid,
|
||||
},
|
||||
@@ -36,7 +33,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
async createUserMagic(email: string) {
|
||||
const createdUser: AuthUser = await this.prisma.user.create({
|
||||
const createdUser = await this.prisma.user.create({
|
||||
data: {
|
||||
email: email,
|
||||
accounts: {
|
||||
@@ -52,7 +49,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
async createUserSSO(accessToken, refreshToken, profile) {
|
||||
const createdUser: AuthUser = await this.prisma.user.create({
|
||||
const createdUser = await this.prisma.user.create({
|
||||
data: {
|
||||
name: profile.displayName,
|
||||
email: profile.emails[0].value,
|
||||
@@ -72,7 +69,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
async createProviderAccount(user, accessToken, refreshToken, profile) {
|
||||
const createdProvider: ProviderAccount = await this.prisma.account.create({
|
||||
const createdProvider = await this.prisma.account.create({
|
||||
data: {
|
||||
userId: user.id,
|
||||
provider: profile.provider,
|
||||
|
||||
Reference in New Issue
Block a user