override def login = {
if (S.post_?) {
S.param("username").
flatMap(username => getSingleton.find(By(email, username))) match {
case Full(user) if user.validated.get &&
!user.locked.get &&
user.password.match_?(S.param("password").openOr("*")) =>
S.notice(S.?("logged.in"))
user.loginAttempts(0).save()
logUserIn(user)
val redir = loginRedirect.is match {
case Full(url) =>
loginRedirect(Empty)
url
case _ =>
homePage
}
S.redirectTo(redir)
case Full(user) if !user.validated.get =>
S.error(S.?("account.validation.error"))
case Full(user) if user.locked.get => {
S.error("Account is Locked")
}
case Full(user) if !user.password.match_?(S.param("password").openOr("*")) => {
println("Invalid Password, updating # of Login Attempts")
var previousAttempts = user.loginAttempts.get
user.loginAttempts(previousAttempts + 1).save()
if (previousAttempts + 1 > 2) {
user.locked(true).save()
}
S.error(S.?("invalid.credentials"))
}
case _ => {
S.error(S.?("invalid.credentials"))
}
}
}
bind("user", loginXhtml,
"email" -> (FocusOnLoad(<input type="text" name="username"/>)),
"password" -> (<input type="password" name="password"/>),
"submit" -> (<input type="submit" class="btn primary" value={S.?("log.in")}/>))
}
--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.