gorm update
This commit is contained in:
@@ -167,11 +167,15 @@ func (h *UserHandler) Login(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
if h.Middleware.IsAuth(ctx) && h.Middleware.RefreshToken(ctx) {
|
||||
http.Redirect(w, r, "/home.html", http.StatusFound)
|
||||
return
|
||||
user := h.AuthUser(ctx)
|
||||
if user.ID > 0 {
|
||||
if err := h.RenewToken(ctx); err == nil {
|
||||
http.Redirect(w, r, "/home.html", http.StatusFound)
|
||||
return
|
||||
}
|
||||
}
|
||||
_ = h.Middleware.Destroy(ctx)
|
||||
|
||||
_ = h.Destroy(ctx)
|
||||
h.HTML(w, r, "oauth/login.tmpl", nil)
|
||||
case http.MethodPost:
|
||||
defer func(Body io.ReadCloser) {
|
||||
@@ -207,7 +211,7 @@ func (h *UserHandler) Login(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (h *UserHandler) Logout(w http.ResponseWriter, r *http.Request) {
|
||||
err := h.Middleware.Destroy(r.Context())
|
||||
err := h.Destroy(r.Context())
|
||||
if err != nil {
|
||||
h.Log.Error(err.Error(), err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user