summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-08 00:59:14 -0500
committerUnknwon <u@gogs.io>2015-12-08 00:59:14 -0500
commit2528c482e9d340945b6e98e7dcde2b4866119631 (patch)
treec2212d66a3c1b30913055c1bd6aa514c1c4f50f9 /routers
parentb1a53f6d8e4a10a9debe5aff084f0c63c1b708aa (diff)
downloadgitea-2528c482e9d340945b6e98e7dcde2b4866119631.tar.gz
gitea-2528c482e9d340945b6e98e7dcde2b4866119631.zip
#1627 auto login after install if admin is configured
Diffstat (limited to 'routers')
-rw-r--r--routers/install.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/routers/install.go b/routers/install.go
index dc0ff2f2f1..c47df0a54a 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -332,15 +332,16 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
GlobalInit()
- // Create admin account.
+ // Create admin account
if len(form.AdminName) > 0 {
- if err := models.CreateUser(&models.User{
+ u := &models.User{
Name: form.AdminName,
Email: form.AdminEmail,
Passwd: form.AdminPasswd,
IsAdmin: true,
IsActive: true,
- }); err != nil {
+ }
+ if err := models.CreateUser(u); err != nil {
if !models.IsErrUserAlreadyExist(err) {
setting.InstallLock = false
ctx.Data["Err_AdminName"] = true
@@ -349,7 +350,12 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
return
}
log.Info("Admin account already exist")
+ u, _ = models.GetUserByName(u.Name)
}
+
+ // Auto-login for admin
+ ctx.Session.Set("uid", u.Id)
+ ctx.Session.Set("uname", u.Name)
}
log.Info("First-time run install finished!")