修复第一次查询「授权令牌」的错误
This commit is contained in:
@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ import (
|
|||||||
"next-terminal/server/utils"
|
"next-terminal/server/utils"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AccountApi struct{}
|
type AccountApi struct{}
|
||||||
@ -345,8 +347,12 @@ func (api AccountApi) AccessTokenGetEndpoint(c echo.Context) error {
|
|||||||
account, _ := GetCurrentAccount(c)
|
account, _ := GetCurrentAccount(c)
|
||||||
accessToken, err := repository.AccessTokenRepository.FindByUserId(context.TODO(), account.ID)
|
accessToken, err := repository.AccessTokenRepository.FindByUserId(context.TODO(), account.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(gorm.ErrRecordNotFound, err) {
|
||||||
|
accessToken = model.AccessToken{}
|
||||||
|
} else {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Success(c, accessToken)
|
return Success(c, accessToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user