@@ -65,7 +65,7 @@ func (c *ApiController) HandleLoggedIn(application *object.Application, user *ob
65
65
return
66
66
}
67
67
if ! allowed {
68
- c .ResponseError (c .T ("AuthErr. Unauthorized" ))
68
+ c .ResponseError (c .T ("auth: Unauthorized operation " ))
69
69
return
70
70
}
71
71
@@ -84,7 +84,7 @@ func (c *ApiController) HandleLoggedIn(application *object.Application, user *ob
84
84
codeChallenge := c .Input ().Get ("code_challenge" )
85
85
86
86
if challengeMethod != "S256" && challengeMethod != "null" && challengeMethod != "" {
87
- c .ResponseError (c .T ("AuthErr.ChallengeMethodErr " ))
87
+ c .ResponseError (c .T ("auth:Challenge method should be S256 " ))
88
88
return
89
89
}
90
90
code := object .GetOAuthCode (userId , clientId , responseType , redirectUri , scope , state , nonce , codeChallenge , c .Ctx .Request .Host , c .GetAcceptLanguage ())
@@ -205,7 +205,7 @@ func (c *ApiController) Login() {
205
205
if form .Username != "" {
206
206
if form .Type == ResponseTypeLogin {
207
207
if c .GetSessionUsername () != "" {
208
- c .ResponseError (c .T ("LoginErr.SignOutFirst " ), c .GetSessionUsername ())
208
+ c .ResponseError (c .T ("auth:Please sign out first before signing in " ), c .GetSessionUsername ())
209
209
return
210
210
}
211
211
}
@@ -231,7 +231,7 @@ func (c *ApiController) Login() {
231
231
} else {
232
232
verificationCodeType = "phone"
233
233
if len (form .PhonePrefix ) == 0 {
234
- responseText := fmt .Sprintf (c .T ("PhoneErr.NoPrefix " ), verificationCodeType )
234
+ responseText := fmt .Sprintf (c .T ("auth:%s No phone prefix " ), verificationCodeType )
235
235
c .ResponseError (responseText )
236
236
return
237
237
}
@@ -256,13 +256,13 @@ func (c *ApiController) Login() {
256
256
257
257
user = object .GetUserByFields (form .Organization , form .Username )
258
258
if user == nil {
259
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.UserDoNotExist " ), form .Organization , form .Username ))
259
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The user: %s/%s doesn't exist " ), form .Organization , form .Username ))
260
260
return
261
261
}
262
262
} else {
263
263
application := object .GetApplication (fmt .Sprintf ("admin/%s" , form .Application ))
264
264
if application == nil {
265
- c .ResponseError (fmt .Sprintf (" The application: %s does not exist" , form .Application ))
265
+ c .ResponseError (fmt .Sprintf (c . T ( "auth: The application: %s does not exist") , form .Application ))
266
266
return
267
267
}
268
268
@@ -274,7 +274,7 @@ func (c *ApiController) Login() {
274
274
}
275
275
276
276
if ! isHuman {
277
- c .ResponseError (" Turing test failed." )
277
+ c .ResponseError (c . T ( "auth: Turing test failed.") )
278
278
return
279
279
}
280
280
}
@@ -288,7 +288,7 @@ func (c *ApiController) Login() {
288
288
} else {
289
289
application := object .GetApplication (fmt .Sprintf ("admin/%s" , form .Application ))
290
290
if application == nil {
291
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.AppDoNotExist " ), form .Application ))
291
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The application: %s does not exist " ), form .Application ))
292
292
return
293
293
}
294
294
@@ -302,15 +302,15 @@ func (c *ApiController) Login() {
302
302
} else if form .Provider != "" {
303
303
application := object .GetApplication (fmt .Sprintf ("admin/%s" , form .Application ))
304
304
if application == nil {
305
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.AppDoNotExist " ), form .Application ))
305
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The application: %s does not exist " ), form .Application ))
306
306
return
307
307
}
308
308
309
309
organization := object .GetOrganization (fmt .Sprintf ("%s/%s" , "admin" , application .Organization ))
310
310
provider := object .GetProvider (util .GetId ("admin" , form .Provider ))
311
311
providerItem := application .GetProviderItem (provider .Name )
312
312
if ! providerItem .IsProviderVisible () {
313
- c .ResponseError (fmt .Sprintf (c .T ("ProviderErr.ProviderNotEnabled " ), provider .Name ))
313
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The provider: %s is not enabled for the application " ), provider .Name ))
314
314
return
315
315
}
316
316
@@ -334,14 +334,14 @@ func (c *ApiController) Login() {
334
334
335
335
idProvider := idp .GetIdProvider (provider .Type , provider .SubType , clientId , clientSecret , provider .AppId , form .RedirectUri , provider .Domain , provider .CustomAuthUrl , provider .CustomTokenUrl , provider .CustomUserInfoUrl )
336
336
if idProvider == nil {
337
- c .ResponseError (fmt .Sprintf (c .T ("ProviderErr.ProviderNotSupported " ), provider .Type ))
337
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The provider type: %s is not supported " ), provider .Type ))
338
338
return
339
339
}
340
340
341
341
setHttpClient (idProvider , provider .Type )
342
342
343
343
if form .State != conf .GetConfigString ("authState" ) && form .State != application .Name {
344
- c .ResponseError (fmt .Sprintf (c .T ("AuthErr.AuthStateWrong " ), conf .GetConfigString ("authState" ), form .State ))
344
+ c .ResponseError (fmt .Sprintf (c .T ("auth:State expected: %s, but got: %s " ), conf .GetConfigString ("authState" ), form .State ))
345
345
return
346
346
}
347
347
@@ -353,13 +353,13 @@ func (c *ApiController) Login() {
353
353
}
354
354
355
355
if ! token .Valid () {
356
- c .ResponseError (c .T ("TokenErr.InvalidToken " ))
356
+ c .ResponseError (c .T ("auth:Invalid token " ))
357
357
return
358
358
}
359
359
360
360
userInfo , err = idProvider .GetUserInfo (token )
361
361
if err != nil {
362
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.LoginFail " ), err .Error ()))
362
+ c .ResponseError (fmt .Sprintf (c .T ("auth:Failed to login in: %s " ), err .Error ()))
363
363
return
364
364
}
365
365
}
@@ -376,7 +376,7 @@ func (c *ApiController) Login() {
376
376
// Sign in via OAuth (want to sign up but already have account)
377
377
378
378
if user .IsForbidden {
379
- c .ResponseError (c .T ("LoginErr.UserIsForbidden " ))
379
+ c .ResponseError (c .T ("auth:The user is forbidden to sign in, please contact the administrator " ))
380
380
}
381
381
382
382
resp = c .HandleLoggedIn (application , user , & form )
@@ -388,12 +388,12 @@ func (c *ApiController) Login() {
388
388
} else if provider .Category == "OAuth" {
389
389
// Sign up via OAuth
390
390
if ! application .EnableSignUp {
391
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.AppNotEnableSignUp " ), provider .Type , userInfo .Username , userInfo .DisplayName ))
391
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account, please contact your IT support " ), provider .Type , userInfo .Username , userInfo .DisplayName ))
392
392
return
393
393
}
394
394
395
395
if ! providerItem .CanSignUp {
396
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.ProviderCanNotSignUp " ), provider .Type , userInfo .Username , userInfo .DisplayName , provider .Type ))
396
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The account for provider: %s and username: %s (%s) does not exist and is not allowed to sign up as new account via %%s, please use another way to sign up " ), provider .Type , userInfo .Username , userInfo .DisplayName , provider .Type ))
397
397
return
398
398
}
399
399
@@ -414,7 +414,7 @@ func (c *ApiController) Login() {
414
414
properties ["no" ] = strconv .Itoa (len (object .GetUsers (application .Organization )) + 2 )
415
415
initScore , err := getInitScore ()
416
416
if err != nil {
417
- c .ResponseError (fmt .Errorf (c .T ("InitErr.InitScoreFailed " ), err ).Error ())
417
+ c .ResponseError (fmt .Errorf (c .T ("auth:Get init score failed, error: %w " ), err ).Error ())
418
418
return
419
419
}
420
420
@@ -441,7 +441,7 @@ func (c *ApiController) Login() {
441
441
442
442
affected := object .AddUser (user )
443
443
if ! affected {
444
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.InvalidUserInformation " ), util .StructToJson (user )))
444
+ c .ResponseError (fmt .Sprintf (c .T ("auth:Failed to create user, user information is invalid: %s " ), util .StructToJson (user )))
445
445
return
446
446
}
447
447
@@ -466,13 +466,13 @@ func (c *ApiController) Login() {
466
466
} else { // form.Method != "signup"
467
467
userId := c .GetSessionUsername ()
468
468
if userId == "" {
469
- c .ResponseError (c .T ("LoginErr.AccountDoNotExist " ), userInfo )
469
+ c .ResponseError (c .T ("auth:The account does not exist " ), userInfo )
470
470
return
471
471
}
472
472
473
473
oldUser := object .GetUserByField (application .Organization , provider .Type , userInfo .Id )
474
474
if oldUser != nil {
475
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.OldUser " ), provider .Type , userInfo .Username , userInfo .DisplayName , oldUser .Name , oldUser .DisplayName ))
475
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The account for provider: %s and username: %s (%s) is already linked to another account: %s (%s) " ), provider .Type , userInfo .Username , userInfo .DisplayName , oldUser .Name , oldUser .DisplayName ))
476
476
return
477
477
}
478
478
@@ -493,7 +493,7 @@ func (c *ApiController) Login() {
493
493
// user already signed in to Casdoor, so let the user click the avatar button to do the quick sign-in
494
494
application := object .GetApplication (fmt .Sprintf ("admin/%s" , form .Application ))
495
495
if application == nil {
496
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.AppDoNotExist " ), form .Application ))
496
+ c .ResponseError (fmt .Sprintf (c .T ("auth:The application: %s does not exist " ), form .Application ))
497
497
return
498
498
}
499
499
@@ -505,7 +505,7 @@ func (c *ApiController) Login() {
505
505
record .User = user .Name
506
506
util .SafeGoroutine (func () { object .AddRecord (record ) })
507
507
} else {
508
- c .ResponseError (fmt .Sprintf (c .T ("LoginErr.UnknownAuthentication " ), util .StructToJson (form )))
508
+ c .ResponseError (fmt .Sprintf (c .T ("auth:Unknown authentication type (not password or provider), form = %s " ), util .StructToJson (form )))
509
509
return
510
510
}
511
511
}
0 commit comments