Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ object Application extends Controller with BaseActions {
Ok(html.index())
}

def userPage = Auth(parse.anyContent) {
implicit ctx => {
implicit usr => {
Ok(html.userPage())
}
}
}
}
2 changes: 1 addition & 1 deletion app/controllers/AuthController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ object AuthController extends Controller with SessionSaver[String] with BaseActi
def loginFailed(implicit req: RequestHeader): PlainResult = {
logger.debug("authenticationFailed: " + req)
val cookies = DiscardingCookie(RememberMe.COOKIE_NAME)
Redirect(routes.AuthController.login()) discardingCookies (cookies) flashing (FLASH_ERROR -> "Cannot login with username/password")
Redirect(routes.AuthController.login()) discardingCookies (cookies) flashing (FlashNames.ERROR -> "Cannot login with username/password")
}

//---------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/FlashNames.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package controllers

object FlashNames
{
val INFO = "info"
val ERROR = "error"
val SUCCESS = "success"
}
2 changes: 1 addition & 1 deletion app/controllers/ResetController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object ResetController extends Controller with SessionSaver[String] {

def gotoPasswordResetSucceeded[A](userId: String)(implicit req: RequestHeader) = {
val sessionId = saveAuthentication(userId)
val flash = Flash(Map(FLASH_SUCCESS -> "Your password has been reset."))
val flash = Flash(Map(FlashNames.SUCCESS -> "Your password has been reset."))
Redirect(routes.Application.index()) withCookies SessionCookie("sessionId", sessionId) flashing (flash)
}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/SignupController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object SignupController extends Controller
case e: Exception => {
logger.error("error = ", e)
val errorMessage = "Internal error, could not register"
Redirect(routes.SignupController.signup()) flashing (FLASH_ERROR -> errorMessage)
Redirect(routes.SignupController.signup()) flashing (FlashNames.ERROR -> errorMessage)
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions app/controllers/package.scala

This file was deleted.

20 changes: 20 additions & 0 deletions app/views/userPage.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@()(implicit ctx: MyContext[_], usr: User)

@base.layout() {
<div class="container">
<div class="row">
<div class="span12">
<div class="well" style="height: 600px">
<h1 style="text-align: center">User Page</h1>

<p style="font-size: 20px; text-align: center; margin-top: 15px">
<em>Name:</em><br>
@{usr.name}<br>
<em>email:</em><br>
@{usr.email}<br>
</p>
</div>
</div>
</div>
</div>
}
3 changes: 3 additions & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Home page
GET / controllers.Application.index

# Authenticated user info page
GET /me controllers.Application.userPage

# Authentication
GET /login controllers.AuthController.login
POST /login controllers.AuthController.authenticate
Expand Down
8 changes: 4 additions & 4 deletions test/ApplicationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ApplicationSpec extends Specification
r =>
session(r).get(SESSION_ID) must beSome
cookies(r).get(RememberMe.COOKIE_NAME) must beNone
flash(r).data must not haveKey (controllers.FLASH_ERROR)
flash(r).data must not haveKey (controllers.FlashNames.ERROR)
status(r) must equalTo(SEE_OTHER)
}
}
Expand All @@ -66,7 +66,7 @@ class ApplicationSpec extends Specification
rememberMe.series must beSome
rememberMe.token must beSome

flash(r).data must not haveKey (controllers.FLASH_ERROR)
flash(r).data must not haveKey (controllers.FlashNames.ERROR)
status(r) must equalTo(SEE_OTHER)
}
}
Expand All @@ -76,7 +76,7 @@ class ApplicationSpec extends Specification
("email" -> "email@example.com"),
("password" -> "password"))) must beSome.which {
r =>
flash(r).data must haveKey(controllers.FLASH_ERROR)
flash(r).data must haveKey(controllers.FlashNames.ERROR)
status(r) must equalTo(SEE_OTHER)
}
}
Expand All @@ -89,7 +89,7 @@ class ApplicationSpec extends Specification
("email" -> "email@example.com"),
("password" -> "invalidpassword"))) must beSome.which {
r =>
flash(r).data must haveKey(controllers.FLASH_ERROR)
flash(r).data must haveKey(controllers.FlashNames.ERROR)
status(r) must equalTo(SEE_OTHER)
}
}
Expand Down