|
@@ -17,7 +17,6 @@ import (
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
- "github.com/pkg/errors"
|
|
|
|
"gopkg.in/macaron.v1"
|
|
"gopkg.in/macaron.v1"
|
|
log "unknwon.dev/clog/v2"
|
|
log "unknwon.dev/clog/v2"
|
|
|
|
|
|
@@ -136,15 +135,15 @@ func HTTPContexter() macaron.Handler {
|
|
// or password as the token.
|
|
// or password as the token.
|
|
if authUser == nil {
|
|
if authUser == nil {
|
|
authUser, err = context.AuthenticateByToken(c.Req.Context(), authUsername)
|
|
authUser, err = context.AuthenticateByToken(c.Req.Context(), authUsername)
|
|
- if err != nil && !db.IsErrAccessTokenNotExist(errors.Cause(err)) {
|
|
|
|
|
|
+ if err != nil && !db.IsErrAccessTokenNotExist(err) {
|
|
c.Status(http.StatusInternalServerError)
|
|
c.Status(http.StatusInternalServerError)
|
|
log.Error("Failed to authenticate by access token via username: %v", err)
|
|
log.Error("Failed to authenticate by access token via username: %v", err)
|
|
return
|
|
return
|
|
- } else if db.IsErrAccessTokenNotExist(errors.Cause(err)) {
|
|
|
|
|
|
+ } else if db.IsErrAccessTokenNotExist(err) {
|
|
// Try again using the password field as the token.
|
|
// Try again using the password field as the token.
|
|
authUser, err = context.AuthenticateByToken(c.Req.Context(), authPassword)
|
|
authUser, err = context.AuthenticateByToken(c.Req.Context(), authPassword)
|
|
if err != nil {
|
|
if err != nil {
|
|
- if db.IsErrAccessTokenNotExist(errors.Cause(err)) {
|
|
|
|
|
|
+ if db.IsErrAccessTokenNotExist(err) {
|
|
askCredentials(c, http.StatusUnauthorized, "")
|
|
askCredentials(c, http.StatusUnauthorized, "")
|
|
} else {
|
|
} else {
|
|
c.Status(http.StatusInternalServerError)
|
|
c.Status(http.StatusInternalServerError)
|