This commit is contained in:
parent
6fb7986a7a
commit
4c46386fff
5 changed files with 41 additions and 20 deletions
11
auth.go
11
auth.go
|
@ -32,16 +32,21 @@ func logout(w http.ResponseWriter, ps httprouter.Params, body []byte) HTTPRespon
|
|||
return APIResponse{true}
|
||||
}
|
||||
|
||||
func completeAuth(w http.ResponseWriter, username string, email string, firstname string, lastname string, session *Session) (err error) {
|
||||
func completeAuth(w http.ResponseWriter, username string, email string, firstname string, lastname string, groups string, session *Session) (err error) {
|
||||
var usr User
|
||||
if !userExists(username) {
|
||||
if usr, err = NewUser(username, email, firstname, lastname); err != nil {
|
||||
if usr, err = NewUser(username, email, firstname, lastname, groups); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if usr, err = getUserByLogin(username); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if usr.Groups != groups {
|
||||
usr.Groups = groups
|
||||
usr.Update()
|
||||
}
|
||||
|
||||
if session == nil {
|
||||
var s Session
|
||||
s, err = usr.NewSession()
|
||||
|
@ -73,5 +78,5 @@ func dummyAuth(w http.ResponseWriter, _ httprouter.Params, body []byte) (interfa
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return map[string]string{"status": "OK"}, completeAuth(w, lf["login"], lf["email"], lf["firstname"], lf["lastname"], nil)
|
||||
return map[string]string{"status": "OK"}, completeAuth(w, lf["login"], lf["email"], lf["firstname"], lf["lastname"], "", nil)
|
||||
}
|
||||
|
|
Reference in a new issue