Skip to content

Commit

Permalink
Changed "login" to "username" wherever necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Hrycyszyn committed Nov 19, 2015
1 parent c3e3263 commit 9d0f3ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Expand Up @@ -8,8 +8,8 @@ import com.constructiveproof.hackertracker.models.User
class OurBasicAuthStrategy(protected override val app: ScalatraBase, realm: String)
extends BasicAuthStrategy[User](app, realm) {

protected def validate(userName: String, password: String)(implicit request: HttpServletRequest, response: HttpServletResponse): Option[User] = {
if(userName == "scalatra" && password == "scalatra") Some(User("scalatra"))
protected def validate(username: String, password: String)(implicit request: HttpServletRequest, response: HttpServletResponse): Option[User] = {
if(username == "scalatra" && password == "scalatra") Some(User("scalatra"))
else None
}

Expand Down
Expand Up @@ -15,31 +15,31 @@ class UserPasswordStrategy(protected val app: ScalatraBase)

val logger = LoggerFactory.getLogger(getClass)

private def login = app.params.getOrElse("login", "")
private def username = app.params.getOrElse("username", "")
private def password = app.params.getOrElse("password", "")

/***
* Determine whether the strategy should be run for the current request.
*/
override def isValid(implicit request: HttpServletRequest) = {
logger.info("UserPasswordStrategy: determining isValid: " + (login != "" && password != "").toString())
login != "" && password != ""
logger.info("UserPasswordStrategy: determining isValid: " + (username != "" && password != "").toString())
username != "" && password != ""
}


/**
* In real life, this is where we'd consult our data store, asking it whether the user credentials matched
* any existing user. Here, we'll just check for a known login/password combination and return a user if
* any existing user. Here, we'll just check for a known username/password combination and return a user if
* it's found.
*/
def authenticate()(implicit request: HttpServletRequest, response: HttpServletResponse): Option[User] = {
logger.info("UserPasswordStrategy: attempting authentication")

if(login == "foo" && password == "foo") {
logger.info("UserPasswordStrategy: login succeeded")
if(username == "foo" && password == "foo") {
logger.info("UserPasswordStrategy: username succeeded")
Some(User("foo"))
} else {
logger.info("UserPasswordStrategy: login failed")
logger.info("UserPasswordStrategy: username failed")
None
}
}
Expand Down

0 comments on commit 9d0f3ab

Please sign in to comment.