Rename wrong naming SSO to Passwordless
This commit is contained in:
@@ -11,9 +11,9 @@ import fr.dcproject.messages.Mailer
|
||||
import io.ktor.http.*
|
||||
|
||||
/**
|
||||
* Send an email to the citizen with a link to automatically connect
|
||||
* Send a connexion link by email
|
||||
*/
|
||||
class SsoManager(
|
||||
class PasswordlessAuth(
|
||||
private val mailer: Mailer,
|
||||
private val domain: String,
|
||||
private val citizenRepo: CitizenRepository
|
||||
@@ -27,7 +27,7 @@ class SsoManager(
|
||||
mailer.sendEmail {
|
||||
val token = citizen.user.makeToken()
|
||||
Mail(
|
||||
Email("sso@$domain"),
|
||||
Email("passwordless-auth@$domain"),
|
||||
"Connection",
|
||||
Email(citizen.email),
|
||||
Content("text/plain", generateContent(token, url))
|
||||
@@ -1,7 +1,7 @@
|
||||
package fr.dcproject.component.auth.routes
|
||||
|
||||
import fr.dcproject.component.auth.SsoManager
|
||||
import fr.dcproject.component.auth.routes.SsoRequest.Input
|
||||
import fr.dcproject.component.auth.PasswordlessAuth
|
||||
import fr.dcproject.component.auth.routes.PasswordlessRequest.Input
|
||||
import io.ktor.application.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.locations.*
|
||||
@@ -11,8 +11,8 @@ import io.ktor.routing.*
|
||||
import io.ktor.util.*
|
||||
|
||||
@KtorExperimentalLocationsAPI
|
||||
@Location("/sso")
|
||||
class SsoRequest {
|
||||
@Location("/auth/passwordless")
|
||||
class PasswordlessRequest {
|
||||
data class Input(val email: String, val url: String)
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ class SsoRequest {
|
||||
*/
|
||||
@KtorExperimentalLocationsAPI
|
||||
@KtorExperimentalAPI
|
||||
fun Route.authSso(ssoManager: SsoManager) {
|
||||
post<SsoRequest> {
|
||||
fun Route.authPasswordless(passwordlessAuth: PasswordlessAuth) {
|
||||
post<PasswordlessRequest> {
|
||||
call.receive<Input>().run {
|
||||
try {
|
||||
ssoManager.sendEmail(email, url)
|
||||
} catch (e: SsoManager.EmailNotFound) {
|
||||
passwordlessAuth.sendEmail(email, url)
|
||||
} catch (e: PasswordlessAuth.EmailNotFound) {
|
||||
call.respond(HttpStatusCode.NotFound)
|
||||
}
|
||||
call.respond(HttpStatusCode.NoContent)
|
||||
|
||||
Reference in New Issue
Block a user