Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
puni9869 committed May 20, 2024
1 parent 4291f3d commit 1fae21e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@ func LoginPost(c *gin.Context) {
session := sessions.Default(c)
currentlyLoggedIn := session.Get(userkey)
log.WithField("email", email).Info("login found ", currentlyLoggedIn)

if currentlyLoggedIn == nil || currentlyLoggedIn != email {
session.Set(userkey, email)
log.WithField("email", email).Info("setting user", currentlyLoggedIn)

if err := session.Save(); err != nil {
log.WithField("email", email).WithError(result.Error).Error("Unable to save session.")
c.HTML(http.StatusInternalServerError, "login.tmpl", gin.H{"HasError": true, "Error": "Something went wrong. We are working on it."})
c.Abort()
}

log.WithField("email", email).Info("set user", currentlyLoggedIn)
}

log.WithField("user", user).Info("user currently logged in")
// Redirect to the home route upon successful login
c.Redirect(http.StatusPermanentRedirect, "/")
Expand Down

0 comments on commit 1fae21e

Please sign in to comment.