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