Browse Source

#2937 able to prohibit user login

for-closed-social
Unknwon 8 years ago
parent
commit
c083d76567
11 changed files with 41 additions and 6 deletions
  1. +1
    -1
      README.md
  2. +3
    -0
      conf/locale/locale_en-US.ini
  3. +1
    -1
      gogs.go
  4. +1
    -0
      models/user.go
  5. +1
    -0
      modules/auth/admin.go
  6. +2
    -2
      modules/bindata/bindata.go
  7. +8
    -1
      modules/context/auth.go
  8. +1
    -0
      routers/admin/users.go
  9. +1
    -1
      templates/.VERSION
  10. +6
    -0
      templates/admin/user/edit.tmpl
  11. +16
    -0
      templates/user/auth/prohibit_login.tmpl

+ 1
- 1
README.md 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)
##### 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 |
|:-------------:|:-------:|:-------:|

+ 3
- 0
conf/locale/locale_en-US.ini View File

@ -148,6 +148,8 @@ forget_password = Forgot password?
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.
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.
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
@ -890,6 +892,7 @@ users.edit_account = Edit Account
users.max_repo_creation = Maximum Repository Creation Limit
users.max_repo_creation_desc = (Set -1 to use global default limit)
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.allow_git_hook = This account has permissions to create Git hooks
users.allow_import_local = This account has permissions to import local repositories

+ 1
- 1
gogs.go View File

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

+ 1
- 0
models/user.go View File

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

+ 1
- 0
modules/auth/admin.go View File

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

+ 2
- 2
modules/bindata/bindata.go
File diff suppressed because it is too large
View File


+ 8
- 1
modules/context/auth.go View File

@ -29,7 +29,14 @@ func Toggle(options *ToggleOptions) macaron.Handler {
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 {
ctx.Redirect(setting.AppSubUrl + string(setting.LandingPageUrl))
return

+ 1
- 0
routers/admin/users.go View File

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

+ 1
- 1
templates/.VERSION View File

@ -1 +1 @@
0.9.44.0716
0.9.45.0716

+ 6
- 0
templates/admin/user/edit.tmpl View File

@ -73,6 +73,12 @@
<input name="active" type="checkbox" {{if .User.IsActive}}checked{{end}}>
</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="ui checkbox">
<label><strong>{{.i18n.Tr "admin.users.is_admin"}}</strong></label>

+ 16
- 0
templates/user/auth/prohibit_login.tmpl 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" .}}

Loading…
Cancel
Save