progress on password reset

pull/145/head
Thibault Duplessis 2014-12-10 23:30:28 +01:00
parent e2efb15a40
commit 617636c469
6 changed files with 61 additions and 1 deletions

View File

@ -80,4 +80,12 @@ object Auth extends LilaController {
}
)
}
def passwordReset = Open { implicit ctx =>
forms.passwordResetWithCaptcha map {
case (form, captcha) => Ok(html.auth.passwordReset(form, captcha))
}
}
def passwordResetApply = TODO
}

View File

@ -0,0 +1,33 @@
@(form: Form[_], captcha: lila.common.Captcha)(implicit ctx: Context)
@auth.layout(
title = trans.passwordReset.str(),
zen = true) {
<div class="content_box small_box signup">
<div class="signup_box">
<h1 class="lichess_title">@trans.passwordReset()</h1>
<form action="@routes.Auth.passwordResetApply" method="POST">
<ul>
<li class="email">
<label for="@form("email").id">@trans.email()</label>
<input
type="text"
required="required"
name="@form("email").name"
id="@form("email").id"
value="@form("email").value"/>
@errMsg(form("email"))
</li>
<li>
@base.captcha(form("move"), form("gameId"), captcha)
</li>
@errMsg(form)
<li>
<button type="submit" class="submit button" data-icon="F"> Email me a link</button>
</li>
</ul>
</form>
</div>
</div>
}

View File

@ -96,6 +96,7 @@ changePassword=Change password
changeEmail=Change email
email=Email
emailIsOptional=Email is optional. Lichess will use to reset your password if you forget it.
passwordReset=Password reset
learnMoreAboutLichess=Learn more about Lichess
rank=Rank
gamesPlayed=Games played

View File

@ -178,6 +178,8 @@ POST /login controllers.Auth.authenticate
GET /logout controllers.Auth.logout
GET /signup controllers.Auth.signup
POST /signup controllers.Auth.signupPost
GET /password-reset controllers.Auth.passwordReset
POST /password-reset controllers.Auth.passwordResetApply
# Mod
POST /mod/:username/engine controllers.Mod.engine(username: String)

File diff suppressed because one or more lines are too long

View File

@ -32,6 +32,16 @@ final class DataForm(val captcher: akka.actor.ActorSelection) extends lila.hub.C
def signupWithCaptcha = withCaptcha(signup)
val passwordReset = Form(mapping(
"email" -> Forms.email,
"gameId" -> nonEmptyText,
"move" -> nonEmptyText
)(PasswordReset.apply)(_ => None)
.verifying(captchaFailMessage, validateCaptcha _)
)
def passwordResetWithCaptcha = withCaptcha(passwordReset)
val newPassword = Form(single(
"password" -> text(minLength = 4)
))
@ -75,4 +85,9 @@ object DataForm {
password: String,
gameId: String,
move: String)
case class PasswordReset(
email: String,
gameId: String,
move: String)
}