1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 16:44:26 +00:00

#2937 able to prohibit user login

This commit is contained in:
Unknwon 2016-07-16 10:22:16 +08:00
parent 52322ef624
commit c083d76567
11 changed files with 41 additions and 6 deletions

View File

@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
##### Current tip version: 0.9.44 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) ##### Current tip version: 0.9.45 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
| Web | UI | Preview | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

View File

@ -148,6 +148,8 @@ forget_password = Forgot password?
sign_up_now = Need an account? Sign up now. sign_up_now = Need an account? Sign up now.
confirmation_mail_sent_prompt = A new confirmation email has been sent to <b>%s</b>, please check your inbox within the next %d hours to complete the registration process. confirmation_mail_sent_prompt = A new confirmation email has been sent to <b>%s</b>, please check your inbox within the next %d hours to complete the registration process.
active_your_account = Activate Your Account active_your_account = Activate Your Account
prohibit_login = Login Prohibited
prohibit_login_desc = Your account is prohibited to login, please contact site admin.
resent_limit_prompt = Sorry, you already requested an activation email recently. Please wait 3 minutes then try again. resent_limit_prompt = Sorry, you already requested an activation email recently. Please wait 3 minutes then try again.
has_unconfirmed_mail = Hi %s, you have an unconfirmed email address (<b>%s</b>). If you haven't received a confirmation email or need to resend a new one, please click on the button below. has_unconfirmed_mail = Hi %s, you have an unconfirmed email address (<b>%s</b>). If you haven't received a confirmation email or need to resend a new one, please click on the button below.
resend_mail = Click here to resend your activation email resend_mail = Click here to resend your activation email
@ -890,6 +892,7 @@ users.edit_account = Edit Account
users.max_repo_creation = Maximum Repository Creation Limit users.max_repo_creation = Maximum Repository Creation Limit
users.max_repo_creation_desc = (Set -1 to use global default limit) users.max_repo_creation_desc = (Set -1 to use global default limit)
users.is_activated = This account is activated users.is_activated = This account is activated
users.prohibit_login = This account is prohibited to login
users.is_admin = This account has administrator permissions users.is_admin = This account has administrator permissions
users.allow_git_hook = This account has permissions to create Git hooks users.allow_git_hook = This account has permissions to create Git hooks
users.allow_import_local = This account has permissions to import local repositories users.allow_import_local = This account has permissions to import local repositories

View File

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

View File

@ -86,6 +86,7 @@ type User struct {
IsAdmin bool IsAdmin bool
AllowGitHook bool AllowGitHook bool
AllowImportLocal bool // Allow migrate repository by local path AllowImportLocal bool // Allow migrate repository by local path
ProhibitLogin bool
// Avatar // Avatar
Avatar string `xorm:"VARCHAR(2048) NOT NULL"` Avatar string `xorm:"VARCHAR(2048) NOT NULL"`

View File

@ -36,6 +36,7 @@ type AdminEditUserForm struct {
Admin bool Admin bool
AllowGitHook bool AllowGitHook bool
AllowImportLocal bool AllowImportLocal bool
ProhibitLogin bool
} }
func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,14 @@ func Toggle(options *ToggleOptions) macaron.Handler {
return return
} }
// Checking non-logged users landing page. // Check prohibit login users.
if ctx.IsSigned && ctx.User.ProhibitLogin {
ctx.Data["Title"] = ctx.Tr("auth.prohibit_login")
ctx.HTML(200, "user/auth/prohibit_login")
return
}
// Check non-logged users landing page.
if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageUrl != setting.LANDING_PAGE_HOME { if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageUrl != setting.LANDING_PAGE_HOME {
ctx.Redirect(setting.AppSubUrl + string(setting.LandingPageUrl)) ctx.Redirect(setting.AppSubUrl + string(setting.LandingPageUrl))
return return

View File

@ -206,6 +206,7 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
u.IsAdmin = form.Admin u.IsAdmin = form.Admin
u.AllowGitHook = form.AllowGitHook u.AllowGitHook = form.AllowGitHook
u.AllowImportLocal = form.AllowImportLocal u.AllowImportLocal = form.AllowImportLocal
u.ProhibitLogin = form.ProhibitLogin
if err := models.UpdateUser(u); err != nil { if err := models.UpdateUser(u); err != nil {
if models.IsErrEmailAlreadyUsed(err) { if models.IsErrEmailAlreadyUsed(err) {

View File

@ -1 +1 @@
0.9.44.0716 0.9.45.0716

View File

@ -73,6 +73,12 @@
<input name="active" type="checkbox" {{if .User.IsActive}}checked{{end}}> <input name="active" type="checkbox" {{if .User.IsActive}}checked{{end}}>
</div> </div>
</div> </div>
<div class="inline field">
<div class="ui checkbox">
<label><strong>{{.i18n.Tr "admin.users.prohibit_login"}}</strong></label>
<input name="prohibit_login" type="checkbox" {{if .User.ProhibitLogin}}checked{{end}}>
</div>
</div>
<div class="inline field"> <div class="inline field">
<div class="ui checkbox"> <div class="ui checkbox">
<label><strong>{{.i18n.Tr "admin.users.is_admin"}}</strong></label> <label><strong>{{.i18n.Tr "admin.users.is_admin"}}</strong></label>

View File

@ -0,0 +1,16 @@
{{template "base/head" .}}
<div class="user activate">
<div class="ui middle very relaxed page grid">
<div class="column">
<form class="ui form">
<h2 class="ui top attached header">
{{.i18n.Tr "auth.prohibit_login"}}
</h2>
<div class="ui attached segment">
<p>{{.i18n.Tr "auth.prohibit_login_desc"}}</p>
</div>
</form>
</div>
</div>
</div>
{{template "base/footer" .}}