Refactor forgejo user interaction
This commit is contained in:
parent
a01f6dec23
commit
a1c5827641
2 changed files with 16 additions and 27 deletions
|
|
@ -97,27 +97,14 @@ func (s *SessionStore) CallbackViewOAUTH(w http.ResponseWriter, r *http.Request)
|
|||
return
|
||||
}
|
||||
|
||||
data, err := auth.GetUserData(r.FormValue("code"), s.oauth)
|
||||
username, err := auth.GetUserFromForgejo(r.FormValue("code"), s.oauth)
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
|
||||
username, ok := data["preferred_username"]
|
||||
if !ok {
|
||||
log.Println("No username in auth response")
|
||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
userStr, ok := username.(string)
|
||||
if !ok {
|
||||
log.Println("Username not interpretable as string")
|
||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||
return
|
||||
}
|
||||
|
||||
s.Login(userStr, w)
|
||||
s.Login(username, w)
|
||||
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue