0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-17 23:41:49 +01:00

#1627 auto login after install if admin is configured

This commit is contained in:
Unknwon 2015-12-08 00:59:14 -05:00
parent b1a53f6d8e
commit 2528c482e9
4 changed files with 12 additions and 6 deletions

View file

@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](public/img/gogs-large-resize.png) ![](public/img/gogs-large-resize.png)
##### Current version: 0.7.33 Beta ##### Current version: 0.7.34 Beta
| Web | UI | Preview | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

View file

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.7.33.1206 Beta" const APP_VER = "0.7.34.1208 Beta"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

View file

@ -332,15 +332,16 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
GlobalInit() GlobalInit()
// Create admin account. // Create admin account
if len(form.AdminName) > 0 { if len(form.AdminName) > 0 {
if err := models.CreateUser(&models.User{ u := &models.User{
Name: form.AdminName, Name: form.AdminName,
Email: form.AdminEmail, Email: form.AdminEmail,
Passwd: form.AdminPasswd, Passwd: form.AdminPasswd,
IsAdmin: true, IsAdmin: true,
IsActive: true, IsActive: true,
}); err != nil { }
if err := models.CreateUser(u); err != nil {
if !models.IsErrUserAlreadyExist(err) { if !models.IsErrUserAlreadyExist(err) {
setting.InstallLock = false setting.InstallLock = false
ctx.Data["Err_AdminName"] = true ctx.Data["Err_AdminName"] = true
@ -349,7 +350,12 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
return return
} }
log.Info("Admin account already exist") 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!") log.Info("First-time run install finished!")

View file

@ -1 +1 @@
0.7.33.1206 Beta 0.7.34.1208 Beta