mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-04 20:45:58 +01:00
Add SignInController.
This commit is contained in:
@@ -5,6 +5,7 @@ import javax.servlet._
|
||||
class ScalatraBootstrap extends LifeCycle {
|
||||
override def init(context: ServletContext) {
|
||||
context.mount(new IndexController, "/")
|
||||
context.mount(new SignInController, "/*")
|
||||
context.mount(new WikiController, "/*")
|
||||
context.mount(new CreateRepositoryController, "/*")
|
||||
context.mount(new RepositoryViewerController, "/*")
|
||||
|
||||
21
src/main/scala/app/SignInController.scala
Normal file
21
src/main/scala/app/SignInController.scala
Normal file
@@ -0,0 +1,21 @@
|
||||
package app
|
||||
|
||||
import jp.sf.amateras.scalatra.forms._
|
||||
|
||||
class SignInController extends ControllerBase {
|
||||
|
||||
case class SignInForm(email: String, password: String)
|
||||
|
||||
val form = mapping(
|
||||
"email" -> trim(label("Email", text(required))),
|
||||
"password" -> trim(label("Password", text(required)))
|
||||
)(SignInForm.apply)
|
||||
|
||||
get("/signin"){
|
||||
html.signin()
|
||||
}
|
||||
|
||||
post("/signin", form){ form =>
|
||||
redirect("/%s".format(context.loginUser))
|
||||
}
|
||||
}
|
||||
15
src/main/twirl/signin.scala.html
Normal file
15
src/main/twirl/signin.scala.html
Normal file
@@ -0,0 +1,15 @@
|
||||
@()(implicit context: app.Context)
|
||||
@import context._
|
||||
@main("Sign in"){
|
||||
<form action="@path/signin" method="POST" validate="true">
|
||||
<label for="email">Email</label>
|
||||
<input type="text" name="email" id="email"/>
|
||||
<span id="error-email" class="error-message"></span>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" name="password" id="password"/>
|
||||
<span id="error-password" class="error-message"></span>
|
||||
<div>
|
||||
<input type="submit" class="btn btn-primary" value="Sign in"/>
|
||||
</div>
|
||||
</form>
|
||||
}
|
||||
Reference in New Issue
Block a user