~jan0sch/smederee
Showing details for patch f8cb576f46a51aa7d4a4d3ee2517835b959dde87.
diff -rN -u old-smederee/modules/hub/src/main/resources/messages.properties new-smederee/modules/hub/src/main/resources/messages.properties --- old-smederee/modules/hub/src/main/resources/messages.properties 2025-01-15 16:01:17.324261130 +0000 +++ new-smederee/modules/hub/src/main/resources/messages.properties 2025-01-15 16:01:17.328261144 +0000 @@ -70,6 +70,7 @@ form.fork.button.submit.not-validated=Please validate your account first, only validated users can create repositories. form.fork.help=Please remember that darcs has a different nomenclature than for example git. Cloning this repository to your account will create a branch (equal to a git fork). form.login.button.submit=Login +form.login.link.reset-password=I forgot my password. form.login.password=Password form.login.password.placeholder=Please enter your password here. form.login.username=Username diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala --- old-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala 2025-01-15 16:01:17.324261130 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala 2025-01-15 16:01:17.328261144 +0000 @@ -80,6 +80,7 @@ private val log = LoggerFactory.getLogger(getClass) private val loginPath = uri"/login" + private val resetPath = uri"/forgot-password" private val parseLoginForm: HttpRoutes[F] = HttpRoutes.of[F] { case request @ POST -> Root / "login" => request.decodeStrict[F, UrlForm] { urlForm => @@ -98,7 +99,7 @@ response <- form match { case Validated.Invalid(es) => BadRequest( - views.html.login()(loginPath, csrf, title = "Smederee - Login to your account".some)( + views.html.login()(loginPath, csrf, resetPath, title = "Smederee - Login to your account".some)( formData, FormErrors.fromNec(es) ) @@ -137,7 +138,7 @@ response <- login match { case Left(_) => BadRequest( - views.html.login()(loginPath, csrf, title = "Smederee - Login to your account".some)( + views.html.login()(loginPath, csrf, resetPath, title = "Smederee - Login to your account".some)( formData, Map(LoginForm.fieldGlobal -> List(FormFieldError("Invalid credentials!"))) ) @@ -171,8 +172,6 @@ SeeOther(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. } - // private val parseResetPasswordForm = ??? - private val logout: AuthedRoutes[Account, F] = AuthedRoutes.of { case ar @ POST -> Root / "logout" as _ => for { authToken <- Sync[F].delay(ar.req.getAuthenticationToken) @@ -185,7 +184,7 @@ private val showLoginForm: HttpRoutes[F] = HttpRoutes.of { case req @ GET -> Root / "login" => for { csrf <- Sync[F].delay(req.getCsrfToken) - response <- Ok(views.html.login()(loginPath, csrf, title = "Smederee - Login to your account".some)()) + response <- Ok(views.html.login()(loginPath, csrf, resetPath, title = "Smederee - Login to your account".some)()) } yield response } @@ -194,8 +193,6 @@ SeeOther(Location(Uri(path = Uri.Path.Root))) // Redirect already logged in users. } - // private val showResetPasswordForm = ??? - // private val unlockUser = ??? val protectedRoutes = diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/login.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/login.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/login.scala.html 2025-01-15 16:01:17.328261144 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/login.scala.html 2025-01-15 16:01:17.328261144 +0000 @@ -3,7 +3,7 @@ @import LoginForm._ @import de.smederee.hub.views.html.forms.renderFormErrors -@(baseUri: Uri = Uri(path = Uri.Path.Root), lang: LanguageCode = LanguageCode("en"))(action: Uri, csrf: Option[CsrfToken] = None, title: Option[String] = None)(formData: Map[String, String] = Map.empty, formErrors: FormErrors = FormErrors.empty) +@(baseUri: Uri = Uri(path = Uri.Path.Root), lang: LanguageCode = LanguageCode("en"))(action: Uri, csrf: Option[CsrfToken] = None, resetPasswordUri: Uri, title: Option[String] = None)(formData: Map[String, String] = Map.empty, formErrors: FormErrors = FormErrors.empty) @main(baseUri, lang)()(csrf, title, user = None) { @defining(lang.toLocale) { implicit locale => <div class="content"> @@ -12,13 +12,13 @@ <div class="l-box"> <div class="form-errors"> @formErrors.get(fieldGlobal).map { es => - @for(error <- es) { - <p class="alert alert-error"> - <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> - <span class="sr-only">Fehler:</span> - @error - </p> - } + @for(error <- es) { + <p class="alert alert-error"> + <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> + <span class="sr-only">Fehler:</span> + @error + </p> + } } </div> <div class="login-form"> @@ -37,6 +37,7 @@ @csrfToken(csrf) <div class="pure-controls"> <button type="submit" class="pure-button">@Messages("form.login.button.submit")</button> + <a href="@resetPasswordUri">@Messages("form.login.link.reset-password")</a> </div> </fieldset> </form>