Skip to content

Commit

Permalink
MOBILE-242 | Password Reset is failing from mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
wlara committed Aug 20, 2024
1 parent 7c89f71 commit 73321b9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 41 deletions.
63 changes: 34 additions & 29 deletions newm-server/src/main/kotlin/io/newm/server/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,42 @@ fun main(args: Array<String>) =

@Suppress("unused")
fun Application.module() {
initializeSentry()
installDependencyInjection()
initializeDatabase()
installCurator()
try {
initializeSentry()
installDependencyInjection()
initializeDatabase()
installCurator()

installCallLogging()
installContentNegotiation()
installAuthentication()
installStatusPages()
installCORS()
installForwarder()
installHealthCheck()
installCallLogging()
installContentNegotiation()
installAuthentication()
installStatusPages()
installCORS()
installForwarder()
installHealthCheck()

routing {
createStaticContentRoutes()
createAuthenticationRoutes()
createUserRoutes()
createCardanoRoutes()
createSongRoutes()
createCollaborationRoutes()
createPlaylistRoutes()
createCloudinaryRoutes()
createIdenfyRoutes()
createDistributionRoutes()
createEarningsRoutes()
createWalletConnectionRoutes()
createMarketplaceRoutes()
createClientConfigRoutes()
routing {
createStaticContentRoutes()
createAuthenticationRoutes()
createUserRoutes()
createCardanoRoutes()
createSongRoutes()
createCollaborationRoutes()
createPlaylistRoutes()
createCloudinaryRoutes()
createIdenfyRoutes()
createDistributionRoutes()
createEarningsRoutes()
createWalletConnectionRoutes()
createMarketplaceRoutes()
createClientConfigRoutes()

createOpenApiDocumentationRoutes()
}
createOpenApiDocumentationRoutes()
}

initializeDaemons()
initializeDaemons()
} catch (t: Throwable) {
t.printStackTrace()
throw t
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ internal class UserRepositoryImpl(
val email = user.email?.asValidEmail()?.asVerifiedEmail(user.authCode)
val passwordHash = user.newPassword?.asValidPassword(user.confirmPassword)?.toHash()

newSuspendedTransaction {
val userEntity = newSuspendedTransaction {
val entity = UserEntity[userId]
user.firstName?.let {
entity.checkNameModifiable(it, entity.firstName)
Expand Down Expand Up @@ -285,6 +285,10 @@ internal class UserRepositoryImpl(
user.distributionLabelId?.let { entity.distributionLabelId = it }
user.distributionIsni?.let { entity.distributionIsni = it.orNull() }
user.distributionIpn?.let { entity.distributionIpn = it.orNull() }
entity
}
passwordHash?.let {
userEntity.notifyPasswordChanged()
}
}

Expand Down Expand Up @@ -340,12 +344,7 @@ internal class UserRepositoryImpl(
this.passwordHash = passwordHash
}
}
emailRepository.send(
to = email,
subject = environment.getConfigString("passwordChanged.subject"),
messageUrl = environment.getConfigString("passwordChanged.messageUrl"),
messageArgs = mapOf("owner" to userEntity.stageOrFullName)
)
userEntity.notifyPasswordChanged()
}

override suspend fun delete(userId: UserId) {
Expand Down Expand Up @@ -426,4 +425,13 @@ internal class UserRepositoryImpl(
biography?.checkLength("biography", 250)
companyName?.checkLength("companyName")
}

private suspend fun UserEntity.notifyPasswordChanged() {
emailRepository.send(
to = email,
subject = environment.getConfigString("passwordChangeNotification.subject"),
messageUrl = environment.getConfigString("passwordChangeNotification.messageUrl"),
messageArgs = mapOf("owner" to stageOrFullName)
)
}
}
11 changes: 6 additions & 5 deletions newm-server/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,12 @@ mintingNotifications {
messageUrl = "/email/mint-released.html"
messageUrl = ${?EMAIL_MINT_RELEASED_MESSAGE_URL}
}
passwordChanged {
subject = "Your password has been reset /Password reset confirmation"
messageUrl = "/email/password-changed.html"
messageUrl = ${?EMAIL_PASSWORD_CHANGED_MESSAGE_URL}
}
}

passwordChangeNotification {
subject = "Your password has been reset /Password reset confirmation"
messageUrl = "/email/password-changed.html"
messageUrl = ${?EMAIL_PASSWORD_CHANGED_MESSAGE_URL}
}

nftCdn {
Expand Down

0 comments on commit 73321b9

Please sign in to comment.