refactor: Set the current user in the request for VerifyJwt middleware
This commit is contained in:
parent
a9d153a22f
commit
40309311bd
|
@ -1,6 +1,7 @@
|
||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.lumeweb.com/LumeWeb/portal/service/account"
|
||||||
"git.lumeweb.com/LumeWeb/portal/service/auth"
|
"git.lumeweb.com/LumeWeb/portal/service/auth"
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
)
|
)
|
||||||
|
@ -13,8 +14,15 @@ func VerifyJwt(ctx iris.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := auth.VerifyLoginToken(token); err != nil {
|
acct, err := auth.VerifyLoginToken(token)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
ctx.StopWithError(iris.StatusUnauthorized, auth.ErrInvalidToken)
|
ctx.StopWithError(iris.StatusUnauthorized, auth.ErrInvalidToken)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = ctx.SetUser(account.NewUser(acct))
|
||||||
|
if err != nil {
|
||||||
|
ctx.StopWithError(iris.StatusInternalServerError, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue