@@ -213,9 +213,9 @@ func SignInPost(ctx *context.Context) {
213
213
214
214
// If this user is enrolled in 2FA, we can't sign the user in just yet.
215
215
// Instead, redirect them to the 2FA authentication page.
216
- _ , err = models .GetTwoFactorByUID (u .ID )
216
+ _ , err = login .GetTwoFactorByUID (u .ID )
217
217
if err != nil {
218
- if models .IsErrTwoFactorNotEnrolled (err ) {
218
+ if login .IsErrTwoFactorNotEnrolled (err ) {
219
219
handleSignIn (ctx , u , form .Remember )
220
220
} else {
221
221
ctx .ServerError ("UserSignIn" , err )
@@ -237,7 +237,7 @@ func SignInPost(ctx *context.Context) {
237
237
return
238
238
}
239
239
240
- regs , err := models .GetU2FRegistrationsByUID (u .ID )
240
+ regs , err := login .GetU2FRegistrationsByUID (u .ID )
241
241
if err == nil && len (regs ) > 0 {
242
242
ctx .Redirect (setting .AppSubURL + "/user/u2f" )
243
243
return
@@ -277,7 +277,7 @@ func TwoFactorPost(ctx *context.Context) {
277
277
}
278
278
279
279
id := idSess .(int64 )
280
- twofa , err := models .GetTwoFactorByUID (id )
280
+ twofa , err := login .GetTwoFactorByUID (id )
281
281
if err != nil {
282
282
ctx .ServerError ("UserSignIn" , err )
283
283
return
@@ -313,7 +313,7 @@ func TwoFactorPost(ctx *context.Context) {
313
313
}
314
314
315
315
twofa .LastUsedPasscode = form .Passcode
316
- if err = models .UpdateTwoFactor (twofa ); err != nil {
316
+ if err = login .UpdateTwoFactor (twofa ); err != nil {
317
317
ctx .ServerError ("UserSignIn" , err )
318
318
return
319
319
}
@@ -356,7 +356,7 @@ func TwoFactorScratchPost(ctx *context.Context) {
356
356
}
357
357
358
358
id := idSess .(int64 )
359
- twofa , err := models .GetTwoFactorByUID (id )
359
+ twofa , err := login .GetTwoFactorByUID (id )
360
360
if err != nil {
361
361
ctx .ServerError ("UserSignIn" , err )
362
362
return
@@ -370,7 +370,7 @@ func TwoFactorScratchPost(ctx *context.Context) {
370
370
ctx .ServerError ("UserSignIn" , err )
371
371
return
372
372
}
373
- if err = models .UpdateTwoFactor (twofa ); err != nil {
373
+ if err = login .UpdateTwoFactor (twofa ); err != nil {
374
374
ctx .ServerError ("UserSignIn" , err )
375
375
return
376
376
}
@@ -418,7 +418,7 @@ func U2FChallenge(ctx *context.Context) {
418
418
return
419
419
}
420
420
id := idSess .(int64 )
421
- regs , err := models .GetU2FRegistrationsByUID (id )
421
+ regs , err := login .GetU2FRegistrationsByUID (id )
422
422
if err != nil {
423
423
ctx .ServerError ("UserSignIn" , err )
424
424
return
@@ -454,7 +454,7 @@ func U2FSign(ctx *context.Context) {
454
454
}
455
455
challenge := challSess .(* u2f.Challenge )
456
456
id := idSess .(int64 )
457
- regs , err := models .GetU2FRegistrationsByUID (id )
457
+ regs , err := login .GetU2FRegistrationsByUID (id )
458
458
if err != nil {
459
459
ctx .ServerError ("UserSignIn" , err )
460
460
return
@@ -717,8 +717,8 @@ func handleOAuth2SignIn(ctx *context.Context, source *login.Source, u *models.Us
717
717
718
718
needs2FA := false
719
719
if ! source .Cfg .(* oauth2.Source ).SkipLocalTwoFA {
720
- _ , err := models .GetTwoFactorByUID (u .ID )
721
- if err != nil && ! models .IsErrTwoFactorNotEnrolled (err ) {
720
+ _ , err := login .GetTwoFactorByUID (u .ID )
721
+ if err != nil && ! login .IsErrTwoFactorNotEnrolled (err ) {
722
722
ctx .ServerError ("UserSignIn" , err )
723
723
return
724
724
}
@@ -775,7 +775,7 @@ func handleOAuth2SignIn(ctx *context.Context, source *login.Source, u *models.Us
775
775
}
776
776
777
777
// If U2F is enrolled -> Redirect to U2F instead
778
- regs , err := models .GetU2FRegistrationsByUID (u .ID )
778
+ regs , err := login .GetU2FRegistrationsByUID (u .ID )
779
779
if err == nil && len (regs ) > 0 {
780
780
ctx .Redirect (setting .AppSubURL + "/user/u2f" )
781
781
return
@@ -935,9 +935,9 @@ func linkAccount(ctx *context.Context, u *models.User, gothUser goth.User, remem
935
935
// If this user is enrolled in 2FA, we can't sign the user in just yet.
936
936
// Instead, redirect them to the 2FA authentication page.
937
937
// We deliberately ignore the skip local 2fa setting here because we are linking to a previous user here
938
- _ , err := models .GetTwoFactorByUID (u .ID )
938
+ _ , err := login .GetTwoFactorByUID (u .ID )
939
939
if err != nil {
940
- if ! models .IsErrTwoFactorNotEnrolled (err ) {
940
+ if ! login .IsErrTwoFactorNotEnrolled (err ) {
941
941
ctx .ServerError ("UserLinkAccount" , err )
942
942
return
943
943
}
@@ -967,7 +967,7 @@ func linkAccount(ctx *context.Context, u *models.User, gothUser goth.User, remem
967
967
}
968
968
969
969
// If U2F is enrolled -> Redirect to U2F instead
970
- regs , err := models .GetU2FRegistrationsByUID (u .ID )
970
+ regs , err := login .GetU2FRegistrationsByUID (u .ID )
971
971
if err == nil && len (regs ) > 0 {
972
972
ctx .Redirect (setting .AppSubURL + "/user/u2f" )
973
973
return
@@ -1561,7 +1561,7 @@ func ForgotPasswdPost(ctx *context.Context) {
1561
1561
ctx .HTML (http .StatusOK , tplForgotPassword )
1562
1562
}
1563
1563
1564
- func commonResetPassword (ctx * context.Context ) (* models.User , * models .TwoFactor ) {
1564
+ func commonResetPassword (ctx * context.Context ) (* models.User , * login .TwoFactor ) {
1565
1565
code := ctx .FormString ("code" )
1566
1566
1567
1567
ctx .Data ["Title" ] = ctx .Tr ("auth.reset_password" )
@@ -1583,9 +1583,9 @@ func commonResetPassword(ctx *context.Context) (*models.User, *models.TwoFactor)
1583
1583
return nil , nil
1584
1584
}
1585
1585
1586
- twofa , err := models .GetTwoFactorByUID (u .ID )
1586
+ twofa , err := login .GetTwoFactorByUID (u .ID )
1587
1587
if err != nil {
1588
- if ! models .IsErrTwoFactorNotEnrolled (err ) {
1588
+ if ! login .IsErrTwoFactorNotEnrolled (err ) {
1589
1589
ctx .Error (http .StatusInternalServerError , "CommonResetPassword" , err .Error ())
1590
1590
return nil , nil
1591
1591
}
@@ -1680,7 +1680,7 @@ func ResetPasswdPost(ctx *context.Context) {
1680
1680
}
1681
1681
1682
1682
twofa .LastUsedPasscode = passcode
1683
- if err = models .UpdateTwoFactor (twofa ); err != nil {
1683
+ if err = login .UpdateTwoFactor (twofa ); err != nil {
1684
1684
ctx .ServerError ("ResetPasswdPost: UpdateTwoFactor" , err )
1685
1685
return
1686
1686
}
@@ -1712,7 +1712,7 @@ func ResetPasswdPost(ctx *context.Context) {
1712
1712
ctx .ServerError ("UserSignIn" , err )
1713
1713
return
1714
1714
}
1715
- if err = models .UpdateTwoFactor (twofa ); err != nil {
1715
+ if err = login .UpdateTwoFactor (twofa ); err != nil {
1716
1716
ctx .ServerError ("UserSignIn" , err )
1717
1717
return
1718
1718
}
0 commit comments