Skip to content

Commit

Permalink
Latest
Browse files Browse the repository at this point in the history
  • Loading branch information
dataswifty committed Oct 13, 2023
1 parent 351d874 commit 7a525e2
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# db
POSTGRES_USER=testhatdb1
POSTGRES_PASSWORD=pa55w0rd
OSTGRES_PASSWORD=pa55w0rd
POSTGRES_SERVER=postgres
POSTGRES_PORT=5432
POSTGRES_DB=testhatdb1
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ docker-prod:
@sbt ${PROD_DOCKER_SBT_JAVA_OPT} docker:stage


docker-dev:
docker-dev: dev
$(info > Building a docker image to use with docker-compose.)
@sbt ${DEV_DOCKER_SBT_JAVA_OPT} docker:publishLocal

Expand Down
21 changes: 16 additions & 5 deletions hat/app/org/hatdex/hat/api/controllers/Authentication.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import io.dataswift.models.hat.json.HatJsonFormats
import org.hatdex.hat.api.service.applications.ApplicationsService
import org.hatdex.hat.api.service.{ HatServicesService, LogService, MailTokenService, UserService }
import org.hatdex.hat.authentication._
import org.hatdex.hat.client.{ TrustProxyClient }
import org.hatdex.hat.phata.models._
import org.hatdex.hat.resourceManagement.{ HatServerProvider, _ }
import org.hatdex.hat.utils.{ DataswiftServiceConfig, HatBodyParsers, HatMailer, TrustProxyUtils }
Expand Down Expand Up @@ -307,6 +306,8 @@ class Authentication @Inject() (
* Sends an email to the user with a link to reset the password
* This is unauthenticated.
*/

// return token and not email, like the other endpoint
def handleForgotPassword: Action[ApiPasswordResetRequest] =
UserAwareAction.async(parsers.json[ApiPasswordResetRequest]) { implicit request =>
implicit val language: Lang = Lang.defaultLang
Expand Down Expand Up @@ -410,14 +411,21 @@ class Authentication @Inject() (

val claimHatRequest = request.body
val email = request.dynamicEnvironment.ownerEmail
val response = Ok(Json.toJson(SuccessResponse("You will shortly receive an email with claim instructions")))
val response = Ok(Json.toJson(SuccessResponse("You will shortly receive an email with claim instructions AAA")))

println(claimHatRequest.email == email)
println(email)
println(claimHatRequest)

if (claimHatRequest.email == email)
userService
.listUsers()
.map(_.find(u => (u.roles.contains(Owner()) && !(u.roles.contains(Verified("email"))))))
.flatMap {
case Some(user) =>
case Some(user) => {

println(s"found user ${user.email}")

val eventualClaimContext = for {
maybeApplication <- applicationsService
.applicationStatus()(request.dynamicEnvironment, user, request)
Expand Down Expand Up @@ -471,8 +479,11 @@ class Authentication @Inject() (
)
)
}

case None => Future.successful(response)
}
case None => {
println(s"found user ${response}")
Future.successful(response)
}
}
else
Future.successful(response)
Expand Down
5 changes: 3 additions & 2 deletions hat/app/org/hatdex/hat/phata/models/HatClaims.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ case class ApiVerificationRequest(
applicationId: String,
email: String,
redirectUri: String) {
override def toString: String =
s"ApiVerificationRequest(applicationId: $applicationId, email:REDACTED, redirectUri: $redirectUri)"
// override def toString: String =
// s"ApiVerificationRequest(applicationId: $applicationId, email:REDACTED, redirectUri: $redirectUri)"
}

object ApiVerificationRequest {
Expand All @@ -45,6 +45,7 @@ case class ApiVerificationCompletionRequest(
optins: Array[String],
hatName: String,
hatCluster: String,
// make the password Optional
password: String) {
override def toString: String =
s"ApiVerificationCompletionRequest(email:REDACTED, termsAgreed:$termsAgreed, optins:$optins, hatName:$hatName, hatCluster:$hatCluster, password:REDACTED)"
Expand Down
2 changes: 1 addition & 1 deletion hat/conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ resourceManagement {
serverIdleTimeout = ${?RESOURCE_MGMT_SERVER_IDLE_TIMEOUT}
millinerAddress = "https://eu1.hubofallthings.net" #"https://one.dataswift.net/store"
millinerAddress = ${?MILLINER_ADDRESS}
hatSharedSecret = ""
hatSharedSecret = "4b454e4242685c7d4cfcddd4d498a4189d4"
hatSharedSecret = ${?HAT_SHARED_SECRET}
hatDBThreads = 5
hatDBThreads = ${?HAT_DB_THREADS}
Expand Down
20 changes: 11 additions & 9 deletions hat/conf/dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ devhats {
database = {
dataSourceClass = "org.postgresql.ds.PGSimpleDataSource"
properties = {
databaseName = "hatdb"
user = "hatuser"
password = "hatpassword"
databaseName = "testhatdb1"
user = "postgres"
password = ""
serverName = "localhost"
serverName = ${?HAT_DB_SERVERNAME}
}
Expand All @@ -86,9 +86,9 @@ hat {
database = {
dataSourceClass = "org.postgresql.ds.PGSimpleDataSource"
properties = {
databaseName = "hatdb"
user = "hatuser"
password = "hatpassword"
databaseName = "testhatdb1"
user = "postgres"
password = ""
serverName = "localhost"
serverName = ${?HAT_DB_SERVERNAME}
}
Expand Down Expand Up @@ -137,9 +137,11 @@ mO9kGhALaD5okBcI/VuAQiFvBXdK0ii/nVcBApXEu47PG4oYUgPI
database = {
dataSourceClass = "org.postgresql.ds.PGSimpleDataSource"
properties = {
databaseName = "hatdb"
user = "hatuser"
password = "hatpassword"
databaseName = "testhatdb1"
user = "postgres"
password = ""
serverName = "localhost"
serverName = ${?HAT_DB_SERVERNAME}
}
numThreads = 3
idleTimeout = 30 seconds
Expand Down
2 changes: 1 addition & 1 deletion hat/conf/play.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ play {
}

http {
secret.key = "[changeme]"
secret.key = "4b454e4242685c7d4cfcddd4d498a4189d4"
secret.key = ${?APPLICATION_SECRET}
errorHandler = "org.hatdex.hat.utils.ErrorHandler"
forwarded.trustedProxies=["0.0.0.0/0", "::/0"]
Expand Down

0 comments on commit 7a525e2

Please sign in to comment.