@@ -16,12 +16,12 @@ import * as moment from "moment";
16
16
import { ConfigService } from "src/config/config.service" ;
17
17
import { EmailService } from "src/email/email.service" ;
18
18
import { PrismaService } from "src/prisma/prisma.service" ;
19
+ import { OAuthService } from "../oauth/oauth.service" ;
20
+ import { GenericOidcProvider } from "../oauth/provider/genericOidc.provider" ;
21
+ import { UserSevice } from "../user/user.service" ;
19
22
import { AuthRegisterDTO } from "./dto/authRegister.dto" ;
20
23
import { AuthSignInDTO } from "./dto/authSignIn.dto" ;
21
24
import { LdapService } from "./ldap.service" ;
22
- import { GenericOidcProvider } from "../oauth/provider/genericOidc.provider" ;
23
- import { OAuthService } from "../oauth/oauth.service" ;
24
- import { UserSevice } from "../user/user.service" ;
25
25
26
26
@Injectable ( )
27
27
export class AuthService {
@@ -120,10 +120,7 @@ export class AuthService {
120
120
async generateToken ( user : User , oauth ?: { idToken ?: string } ) {
121
121
// TODO: Make all old loginTokens invalid when a new one is created
122
122
// Check if the user has TOTP enabled
123
- if (
124
- user . totpVerified &&
125
- ! ( oauth && this . config . get ( "oauth.ignoreTotp" ) )
126
- ) {
123
+ if ( user . totpVerified && ! ( oauth && this . config . get ( "oauth.ignoreTotp" ) ) ) {
127
124
const loginToken = await this . createLoginToken ( user . id ) ;
128
125
129
126
return { loginToken } ;
@@ -163,7 +160,7 @@ export class AuthService {
163
160
} ,
164
161
} ) ;
165
162
166
- await this . emailService . sendResetPasswordEmail ( user . email , token ) ;
163
+ this . emailService . sendResetPasswordEmail ( user . email , token ) ;
167
164
}
168
165
169
166
async resetPassword ( token : string , newPassword : string ) {
@@ -231,7 +228,10 @@ export class AuthService {
231
228
232
229
if ( refreshTokenId ) {
233
230
const oauthIDToken = await this . prisma . refreshToken
234
- . findFirst ( { select : { oauthIDToken : true } , where : { id : refreshTokenId } } )
231
+ . findFirst ( {
232
+ select : { oauthIDToken : true } ,
233
+ where : { id : refreshTokenId } ,
234
+ } )
235
235
. then ( ( refreshToken ) => refreshToken ?. oauthIDToken )
236
236
. catch ( ( e ) => {
237
237
// Ignore error if refresh token doesn't exist
@@ -249,16 +249,27 @@ export class AuthService {
249
249
const provider = this . oAuthService . availableProviders ( ) [ providerName ] ;
250
250
let signOutFromProviderSupportedAndActivated = false ;
251
251
try {
252
- signOutFromProviderSupportedAndActivated = this . config . get ( `oauth.${ providerName } -signOut` ) ;
252
+ signOutFromProviderSupportedAndActivated = this . config . get (
253
+ `oauth.${ providerName } -signOut` ,
254
+ ) ;
253
255
} catch ( _ ) {
254
256
// Ignore error if the provider is not supported or if the provider sign out is not activated
255
257
}
256
- if ( provider instanceof GenericOidcProvider && signOutFromProviderSupportedAndActivated ) {
257
- const configuration = await provider . getConfiguration ( ) ;
258
- if ( configuration . frontchannel_logout_supported && URL . canParse ( configuration . end_session_endpoint ) ) {
258
+ if (
259
+ provider instanceof GenericOidcProvider &&
260
+ signOutFromProviderSupportedAndActivated
261
+ ) {
262
+ const configuration = await provider . getConfiguration ( ) ;
263
+ if (
264
+ configuration . frontchannel_logout_supported &&
265
+ URL . canParse ( configuration . end_session_endpoint )
266
+ ) {
259
267
const redirectURI = new URL ( configuration . end_session_endpoint ) ;
260
268
redirectURI . searchParams . append ( "id_token_hint" , idTokenHint ) ;
261
- redirectURI . searchParams . append ( "client_id" , this . config . get ( `oauth.${ providerName } -clientId` ) ) ;
269
+ redirectURI . searchParams . append (
270
+ "client_id" ,
271
+ this . config . get ( `oauth.${ providerName } -clientId` ) ,
272
+ ) ;
262
273
return redirectURI . toString ( ) ;
263
274
}
264
275
}
0 commit comments