Merge remote-tracking branch 'origin/master' into feature/editable-dashboard
This commit is contained in:
commit
85201e254e
|
|
@ -19,6 +19,7 @@ func (s *AuthService) FromContext(ctx *gin.Context) (*SessionItem, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.setCookieFromSession(ctx, session)
|
||||||
s.ctx.Services.Sessions.Extend(session)
|
s.ctx.Services.Sessions.Extend(session)
|
||||||
|
|
||||||
return session, nil
|
return session, nil
|
||||||
|
|
@ -31,7 +32,7 @@ func (s *AuthService) Login(ctx *gin.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetCookie(SESSION_ID, session.Id, int(time.Duration(time.Hour*24).Seconds()), "/", "", false, true)
|
s.setCookieFromSession(ctx, session)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -47,11 +48,19 @@ func (s *AuthService) Logout(ctx *gin.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.SetCookie(SESSION_ID, "", 0, "/", "", false, true)
|
s.clearCookie(ctx)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *AuthService) clearCookie(ctx *gin.Context) {
|
||||||
|
ctx.SetCookie(SESSION_ID, "", 0, "/", "", false, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AuthService) setCookieFromSession(ctx *gin.Context, session *SessionItem) {
|
||||||
|
ctx.SetCookie(SESSION_ID, session.Id, int(time.Duration(time.Hour*24).Seconds()), "/", "", false, true)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *AuthService) getSessionFromContext(ctx *gin.Context) (*SessionItem, error) {
|
func (s *AuthService) getSessionFromContext(ctx *gin.Context) (*SessionItem, error) {
|
||||||
cookie, err := ctx.Cookie(SESSION_ID)
|
cookie, err := ctx.Cookie(SESSION_ID)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue