From 2528c482e9d340945b6e98e7dcde2b4866119631 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 8 Dec 2015 00:59:14 -0500 Subject: [PATCH] #1627 auto login after install if admin is configured --- README.md | 2 +- gogs.go | 2 +- routers/install.go | 12 +++++++++--- templates/.VERSION | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5a7215426..c75f1d710 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra ![](public/img/gogs-large-resize.png) -##### Current version: 0.7.33 Beta +##### Current version: 0.7.34 Beta | Web | UI | Preview | |:-------------:|:-------:|:-------:| diff --git a/gogs.go b/gogs.go index b77540a7f..2923566cc 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.7.33.1206 Beta" +const APP_VER = "0.7.34.1208 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/routers/install.go b/routers/install.go index dc0ff2f2f..c47df0a54 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!") diff --git a/templates/.VERSION b/templates/.VERSION index 6b777ab5a..51f5e121b 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.7.33.1206 Beta \ No newline at end of file +0.7.34.1208 Beta \ No newline at end of file