Skip to content

Commit

Permalink
Finalized hashing of password and comparison, added library dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Clayton committed Jun 18, 2019
1 parent 3450cf6 commit 28f71a2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 120 deletions.
5 changes: 4 additions & 1 deletion app/models/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import ExecutionContext.Implicits.global

//uses this library: https://github.com/firebase4s/firebase4s

import io.github.nremond._
//this import is a hashing library: https://github.com/nremond/pbkdf2-scala

//TODO: CHANGE THE PASSWORD!!!!!!!!
case class User() {
@BeanProperty var firstName: String = _
Expand Down Expand Up @@ -54,7 +57,7 @@ object User {
user.setFirstName(firstName)
user.setLastName(lastName)
user.setEmail(email)
user.setPassword(password)
user.setPassword(SecureHash.createHash(password))
user.setAdmin(isAdmin)
user.setBirthYear(0)
user.setHomeTown("")
Expand Down
117 changes: 0 additions & 117 deletions app/utils/SecureHash.scala

This file was deleted.

4 changes: 3 additions & 1 deletion app/utils/ValidateUser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package utils

import models.User
import utils.ValidationStatus.ValidationStatus
import io.github.nremond._
//this import is hashing library: https://github.com/nremond/pbkdf2-scala

case class ValidateUser(email: String, password: String) {

Expand All @@ -11,7 +13,7 @@ case class ValidateUser(email: String, password: String) {
case None => ValidationStatus.ACCOUNT_NOT_FOUND
case Some(user: User) => {
//TODO: do some actual password checking/hashing here later
if (password == user.getPassword) ValidationStatus.SUCCESS else ValidationStatus.PASSWORD_INCORRECT
if (SecureHash.validatePassword(password, user.getPassword)) ValidationStatus.SUCCESS else ValidationStatus.PASSWORD_INCORRECT
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
libraryDependencies += "com.h2database" % "h2" % "1.4.196"
libraryDependencies += "com.github.firebase4s" %% "firebase4s" % "0.0.4"
//libraryDependencies += "com.google.firebase"
//libraryDependencies += "com.google.firebase"
libraryDependencies += "io.github.nremond" %% "pbkdf2-scala" % "0.6.3"

0 comments on commit 28f71a2

Please sign in to comment.