mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Fixing types and using provider type.
This commit is contained in:
parent
3aa1c77947
commit
03b6bdbcf3
4 changed files with 8 additions and 6 deletions
|
|
@ -6,4 +6,6 @@ export type OAuthUser = {
|
|||
username: string;
|
||||
email?: string;
|
||||
email_verified?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export type OAuthProviders = 'github' | 'google' | 'apple'
|
||||
|
|
@ -7,7 +7,7 @@ import { OAuth2RequestError } from 'arctic'
|
|||
import { getCookie, setCookie } from 'hono/cookie'
|
||||
import { TimeSpan } from 'oslo'
|
||||
import { inject, injectable } from 'tsyringe'
|
||||
import type {OAuthUser} from "$lib/server/api/common/types/oauth-user";
|
||||
import type {OAuthUser} from "$lib/server/api/common/types/oauth";
|
||||
|
||||
@injectable()
|
||||
export class OAuthController extends Controller {
|
||||
|
|
@ -41,7 +41,7 @@ export class OAuthController extends Controller {
|
|||
const oAuthUser: OAuthUser = {
|
||||
sub: `${githubUser.id}`,
|
||||
username: githubUser.login,
|
||||
email: null
|
||||
email: undefined
|
||||
}
|
||||
|
||||
const userId = await this.oauthService.handleOAuthUser(oAuthUser, 'github')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { inject, injectable } from 'tsyringe'
|
||||
import { FederatedIdentityRepository } from '../repositories/federated_identity.repository'
|
||||
import { UsersService } from './users.service'
|
||||
import type {OAuthUser} from "$lib/server/api/common/types/oauth-user";
|
||||
import type {OAuthUser, OAuthProviders} from "$lib/server/api/common/types/oauth";
|
||||
|
||||
@injectable()
|
||||
export class OAuthService {
|
||||
|
|
@ -10,7 +10,7 @@ export class OAuthService {
|
|||
@inject(UsersService) private readonly usersService: UsersService,
|
||||
) {}
|
||||
|
||||
async handleOAuthUser(oAuthUser: OAuthUser, oauthProvider: string) {
|
||||
async handleOAuthUser(oAuthUser: OAuthUser, oauthProvider: OAuthProviders) {
|
||||
const federatedUser = await this.federatedIdentityRepository.findOneByFederatedUserIdAndProvider(oAuthUser.sub, oauthProvider)
|
||||
|
||||
if (federatedUser) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { type UpdateUser, UsersRepository } from '../repositories/users.reposito
|
|||
import { CollectionsService } from './collections.service'
|
||||
import { DrizzleService } from './drizzle.service'
|
||||
import { WishlistsService } from './wishlists.service'
|
||||
import type {OAuthUser} from "$lib/server/api/common/types/oauth-user";
|
||||
import type {OAuthUser} from "$lib/server/api/common/types/oauth";
|
||||
|
||||
@injectable()
|
||||
export class UsersService {
|
||||
|
|
|
|||
Loading…
Reference in a new issue