File tree 1 file changed +13
-6
lines changed
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -556,15 +556,22 @@ func GrantApplicationOAuth(ctx *context.Context) {
556
556
ctx .ServerError ("GetOAuth2ApplicationByClientID" , err )
557
557
return
558
558
}
559
- grant , err := app .CreateGrant (ctx , ctx .Doer .ID , form . Scope )
559
+ grant , err := app .GetGrantByUserID (ctx , ctx .Doer .ID )
560
560
if err != nil {
561
- handleAuthorizeError (ctx , AuthorizeError {
562
- State : form .State ,
563
- ErrorDescription : "cannot create grant for user" ,
564
- ErrorCode : ErrorCodeServerError ,
565
- }, form .RedirectURI )
561
+ handleServerError (ctx , form .State , form .RedirectURI )
566
562
return
567
563
}
564
+ if grant == nil {
565
+ grant , err = app .CreateGrant (ctx , ctx .Doer .ID , form .Scope )
566
+ if err != nil {
567
+ handleAuthorizeError (ctx , AuthorizeError {
568
+ State : form .State ,
569
+ ErrorDescription : "cannot create grant for user" ,
570
+ ErrorCode : ErrorCodeServerError ,
571
+ }, form .RedirectURI )
572
+ return
573
+ }
574
+ }
568
575
if len (form .Nonce ) > 0 {
569
576
err := grant .SetNonce (ctx , form .Nonce )
570
577
if err != nil {
You can’t perform that action at this time.
0 commit comments