Skip to content

Commit

Permalink
http/auth.go: new user signup: support auto user dir creation (#788)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys3 authored and hacdias committed Jun 21, 2019
1 parent 5956647 commit fc5e224
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions http/auth.go
Expand Up @@ -2,6 +2,7 @@ package http

import (
"encoding/json"
"log"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -137,6 +138,15 @@ var signupHandler = func(w http.ResponseWriter, r *http.Request, d *data) (int,
}

user.Password = pwd

userHome, err := d.settings.MakeUserDir(user.Username, user.Scope, d.server.Root)
if err != nil {
log.Printf("create user: failed to mkdir user home dir: [%s]", userHome)
return http.StatusInternalServerError, err
}
user.Scope = userHome
log.Printf("new user: %s, home dir: [%s].", user.Username, userHome)

err = d.store.Users.Save(user)
if err == errors.ErrExist {
return http.StatusConflict, err
Expand Down

0 comments on commit fc5e224

Please sign in to comment.