Merge pull request #1434 from tomoki1207/login-failed-message

Show login failed message
This commit is contained in:
Naoki Takezoe
2017-01-26 00:31:39 +09:00
committed by GitHub
3 changed files with 17 additions and 7 deletions

View File

@@ -49,13 +49,18 @@ trait IndexControllerBase extends ControllerBase {
if(redirect.isDefined && redirect.get.startsWith("/")){
flash += Keys.Flash.Redirect -> redirect.get
}
gitbucket.core.html.signin()
gitbucket.core.html.signin(flash.get("userName"), flash.get("password"), flash.get("error"))
}
post("/signin", signinForm){ form =>
authenticate(context.settings, form.userName, form.password) match {
case Some(account) => signin(account)
case None => redirect("/signin")
case None => {
flash += "userName" -> form.userName
flash += "password" -> form.password
flash += "error" -> "Sorry, your Username and/or Password is incorrect. Please try again."
redirect("/signin")
}
}
}

View File

@@ -1,4 +1,6 @@
@()(implicit context: gitbucket.core.controller.Context)
@(userName: Option[Any] = None,
password: Option[Any] = None,
error: Option[Any] = None)(implicit context: gitbucket.core.controller.Context)
@gitbucket.core.html.main("Sign in"){
<div class="content-wrapper main-center">
<div class="content body">
@@ -9,7 +11,8 @@
@Html(information)
</div>
}
@gitbucket.core.html.signinform(context.settings)
@gitbucket.core.helper.html.error(error)
@gitbucket.core.html.signinform(context.settings, userName, password)
</div>
</div>
</div>

View File

@@ -1,4 +1,6 @@
@(systemSettings: gitbucket.core.service.SystemSettingsService.SystemSettings)(implicit context: gitbucket.core.controller.Context)
@(systemSettings: gitbucket.core.service.SystemSettingsService.SystemSettings,
userName: Option[Any] = None,
password: Option[Any] = None)(implicit context: gitbucket.core.controller.Context)
<div class="panel panel-default">
<div class="panel-heading strong">Sign in</div>
<ul class="list-group list-group-flush">
@@ -7,12 +9,12 @@
<div class="form-group">
<label for="userName">Username:</label>
<span id="error-userName" class="error"></span>
<input type="text" name="userName" id="userName" class="form-control" autofocus/>
<input type="text" name="userName" id="userName" class="form-control" autofocus value="@userName"/>
</div>
<div class="form-group">
<label for="password">Password:</label>
<span id="error-password" class="error"></span>
<input type="password" name="password" id="password" class="form-control"/>
<input type="password" name="password" id="password" class="form-control" value="@password"/>
</div>
<input type="submit" class="btn btn-success" value="Sign in"/>
@if(systemSettings.allowAccountRegistration){