translate 2FA settings

pull/6012/head
Thibault Duplessis 2020-02-09 15:23:30 -06:00
parent d0107cdf79
commit 3133de3258
10 changed files with 68 additions and 37 deletions

View File

@ -34,7 +34,9 @@ object layout {
a(activeCls("editProfile"), href := routes.Account.profile())(
trans.editProfile()
),
isGranted(_.Coach) option a(activeCls("coach"), href := routes.Coach.edit)("Coach profile"),
isGranted(_.Coach) option a(activeCls("coach"), href := routes.Coach.edit)(
trans.coach.lichessCoach()
),
div(cls := "sep"),
a(activeCls("password"), href := routes.Account.passwd())(
trans.changePassword()
@ -46,13 +48,13 @@ object layout {
trans.changeUsername()
),
a(activeCls("twofactor"), href := routes.Account.twoFactor())(
"Two-factor authentication"
trans.settings.twoFactorAuth()
),
a(activeCls("security"), href := routes.Account.security())(
trans.security()
),
div(cls := "sep"),
a(href := routes.Plan.index)("Patron"),
a(href := routes.Plan.index)(trans.patron.lichessPatron()),
div(cls := "sep"),
a(activeCls("oauth.token"), href := routes.OAuthToken.index)(
"API Access tokens"

View File

@ -10,7 +10,7 @@ import controllers.routes
object profile {
private val linksHelp = frag(
"Such as Twitter, Facebook, GitHub, Chess.com, ...",
"Twitter, Facebook, GitHub, Chess.com, ...",
br,
"One URL per line."
)
@ -49,7 +49,7 @@ object profile {
)(form3.input(_, typ = "number"))
}
),
form3.group(form("links"), raw("Social media links "), help = Some(linksHelp)) { f =>
form3.group(form("links"), trans.socialMediaLinks(), help = Some(linksHelp)) { f =>
form3.textarea(f)(rows := 5)
},
form3.action(form3.submit(trans.apply()))

View File

@ -9,13 +9,15 @@ import controllers.routes
object twoFactor {
import trans.settings._
private val qrCode = raw(
"""<div style="width: 276px; height: 276px; padding: 10px; background: white; margin: 2em auto;"><div id="qrcode" style="width: 256px; height: 256px;"></div></div>"""
)
def setup(u: lila.user.User, form: play.api.data.Form[_])(implicit ctx: Context) =
account.layout(
title = s"${u.username} - Two-factor authentication",
title = s"${u.username} - ${twoFactorAuth.txt()}",
active = "twofactor",
evenMoreJs = frag(
jsAt("javascripts/vendor/qrcode.min.js"),
@ -23,58 +25,51 @@ object twoFactor {
)
) {
div(cls := "account twofactor box box-pad")(
h1("Setup two-factor authentication"),
h1(twoFactorAuth()),
standardFlash(),
postForm(cls := "form3", action := routes.Account.setupTwoFactor)(
div(cls := "form-group")(twoFactorHelp()),
div(cls := "form-group")(
"Two-factor authentication adds another layer of security to your account."
),
div(cls := "form-group")(
raw(
"""Get an app for two-factor authentication, for example Google Authenticator for <a class="blue" href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2">Android</a> or <a class="blue" href="https://itunes.apple.com/app/google-authenticator/id388497605?mt=8">iOS.</a>"""
twoFactorApp(
a(
href := "https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2"
)("Android"),
a(href := "https://itunes.apple.com/app/google-authenticator/id388497605?mt=8")("iOS")
)
),
div(cls := "form-group")("Scan the QR code with the app."),
div(cls := "form-group")(scanTheCode()),
qrCode,
div(cls := "form-group explanation")(
"Enter your password and the authentication code generated by the app to complete the setup. You will need an authentication code every time you log in."
),
div(cls := "form-group explanation")(enterPassword()),
form3.hidden(form("secret")),
form3.passwordModified(form("passwd"), trans.password())(autofocus),
form3.group(form("token"), raw("Authentication code"))(
form3.group(form("token"), authenticationCode())(
form3.input(_)(pattern := "[0-9]{6}", autocomplete := "off", required)
),
form3.globalError(form),
div(cls := "form-group")(
"Note: If you lose access to your two-factor authentication codes, you can do a password reset via email."
),
form3.action(form3.submit(raw("Enable two-factor authentication")))
div(cls := "form-group")(ifYouLoseAccess()),
form3.action(form3.submit(enableTwoFactor()))
)
)
}
def disable(u: lila.user.User, form: play.api.data.Form[_])(implicit ctx: Context) =
account.layout(
title = s"${u.username} - Two-factor authentication",
title = s"${u.username} - ${twoFactorAuth.txt()}",
active = "twofactor"
) {
div(cls := "account twofactor box box-pad")(
h1(
i(cls := "is-green", dataIcon := "E"),
" Two-factor authentication enabled"
i(cls := "is-green text", dataIcon := "E"),
twoFactorEnabled()
),
standardFlash(),
p("Your account is protected with two-factor authentication."),
postForm(cls := "form3", action := routes.Account.disableTwoFactor)(
p(
"You need your password and an authentication code from your authenticator app to disable two-factor authentication. ",
"If you lost access to your authentication codes, you can also do a password reset via email."
),
p(twoFactorDisable()),
form3.password(form("passwd"), trans.password()),
form3.group(form("token"), raw("Authentication code"))(
form3.group(form("token"), authenticationCode())(
form3.input(_)(pattern := "[0-9]{6}", autocomplete := "off", required)
),
form3.action(form3.submit(raw("Disable two-factor authentication"), icon = None))
form3.action(form3.submit(disableTwoFactor()))
)
)
}

View File

@ -70,7 +70,7 @@ object show {
),
(info.createdByMe || isGranted(_.Admin)) option
a(href := routes.Team.edit(t.id), cls := "button button-empty text", dataIcon := "%")(
trans.settings()
trans.settings.settings()
),
info.createdByMe option
a(

View File

@ -2,7 +2,7 @@ const fs = require('fs-extra');
const parseString = require('xml2js').parseString;
const baseDir = 'translation/source';
const dbs = 'site arena emails learn activity coordinates study clas contact patron coach broadcast streamer'.split(' ');
const dbs = 'site arena emails learn activity coordinates study clas contact patron coach broadcast streamer settings'.split(' ');
function ucfirst(s) {
return s.charAt(0).toUpperCase() + s.slice(1);

View File

@ -76,7 +76,7 @@ lazy val i18n = module("i18n",
MessageCompiler(
sourceDir = new File("translation/source"),
destDir = new File("translation/dest"),
dbs = List("site", "arena", "emails", "learn", "activity", "coordinates", "study", "class", "contact", "patron", "coach", "broadcast", "streamer"),
dbs = List("site", "arena", "emails", "learn", "activity", "coordinates", "study", "class", "contact", "patron", "coach", "broadcast", "streamer", "settings"),
compileTo = (sourceManaged in Compile).value / "messages"
)
}.taskValue,

View File

@ -18,6 +18,7 @@ object I18nDb {
case object Coach extends Ref
case object Broadcast extends Ref
case object Streamer extends Ref
case object Settings extends Ref
val site: Messages = lila.i18n.db.site.Registry.load
val arena: Messages = lila.i18n.db.arena.Registry.load
@ -32,6 +33,7 @@ object I18nDb {
val coach: Messages = lila.i18n.db.coach.Registry.load
val broadcast: Messages = lila.i18n.db.broadcast.Registry.load
val streamer: Messages = lila.i18n.db.streamer.Registry.load
val settings: Messages = lila.i18n.db.settings.Registry.load
def apply(ref: Ref): Messages = ref match {
case Site => site
@ -47,6 +49,7 @@ object I18nDb {
case Coach => coach
case Broadcast => broadcast
case Streamer => streamer
case Settings => settings
}
val langs: Set[Lang] = site.keys.toSet

View File

@ -1,7 +1,7 @@
// Generated with bin/trans-dump.js
package lila.i18n
import I18nDb.{ Activity, Arena, Broadcast, Clas, Coach, Contact, Coordinates, Emails, Learn, Patron, Site, Streamer, Study }
import I18nDb.{ Activity, Arena, Broadcast, Clas, Coach, Contact, Coordinates, Emails, Learn, Patron, Settings, Site, Streamer, Study }
// format: OFF
object I18nKeys {
@ -261,7 +261,6 @@ val `xJoinedTeamY` = new Translated("xJoinedTeamY", Site)
val `xCreatedTeamY` = new Translated("xCreatedTeamY", Site)
val `averageElo` = new Translated("averageElo", Site)
val `location` = new Translated("location", Site)
val `settings` = new Translated("settings", Site)
val `filterGames` = new Translated("filterGames", Site)
val `reset` = new Translated("reset", Site)
val `apply` = new Translated("apply", Site)
@ -356,6 +355,7 @@ val `firstName` = new Translated("firstName", Site)
val `lastName` = new Translated("lastName", Site)
val `biography` = new Translated("biography", Site)
val `country` = new Translated("country", Site)
val `socialMediaLinks` = new Translated("socialMediaLinks", Site)
val `preferences` = new Translated("preferences", Site)
val `inlineNotation` = new Translated("inlineNotation", Site)
val `watchLichessTV` = new Translated("watchLichessTV", Site)
@ -1487,4 +1487,19 @@ val `beSafe` = new Translated("beSafe", Streamer)
val `keepItShort` = new Translated("keepItShort", Streamer)
}
object settings {
val `settings` = new Translated("settings", Settings)
val `twoFactorAuth` = new Translated("twoFactorAuth", Settings)
val `twoFactorHelp` = new Translated("twoFactorHelp", Settings)
val `twoFactorApp` = new Translated("twoFactorApp", Settings)
val `scanTheCode` = new Translated("scanTheCode", Settings)
val `enterPassword` = new Translated("enterPassword", Settings)
val `authenticationCode` = new Translated("authenticationCode", Settings)
val `ifYouLoseAccess` = new Translated("ifYouLoseAccess", Settings)
val `enableTwoFactor` = new Translated("enableTwoFactor", Settings)
val `disableTwoFactor` = new Translated("disableTwoFactor", Settings)
val `twoFactorEnabled` = new Translated("twoFactorEnabled", Settings)
val `twoFactorDisable` = new Translated("twoFactorDisable", Settings)
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="settings">Settings</string>
<string name="twoFactorAuth">Two-factor authentication</string>
<string name="twoFactorHelp">Two-factor authentication adds another layer of security to your account.</string>
<string name="twoFactorApp">Get an app for two-factor authentication, for example Google Authenticator for %s or %s.</string>
<string name="scanTheCode">Scan the QR code with the app.</string>
<string name="enterPassword">Enter your password and the authentication code generated by the app to complete the setup. You will need an authentication code every time you log in.</string>
<string name="authenticationCode">Authentication code</string>
<string name="ifYouLoseAccess">Note: If you lose access to your two-factor authentication codes, you can do a password reset via email.</string>
<string name="enableTwoFactor">Enable two-factor authentication</string>
<string name="disableTwoFactor">Disable two-factor authentication</string>
<string name="twoFactorEnabled">Two-factor authentication enabled</string>
<string name="twoFactorDisable">You need your password and an authentication code from your authenticator app to disable two-factor authentication.
If you lost access to your authentication codes, you can also do a password reset via email.</string>
</resources>

View File

@ -349,7 +349,6 @@
<string name="xCreatedTeamY">%1$s created team %2$s</string>
<string name="averageElo">Average rating</string>
<string name="location">Location</string>
<string name="settings">Settings</string>
<string name="filterGames">Filter games</string>
<string name="reset">Reset</string>
<string name="apply">Submit</string>
@ -465,6 +464,7 @@ computer analysis, game chat and shareable URL.</string>
<string name="lastName">Surname</string>
<string name="biography">Biography</string>
<string name="country">Country</string>
<string name="socialMediaLinks">Social media links</string>
<string name="preferences">Preferences</string>
<string name="inlineNotation">Inline notation</string>
<string name="watchLichessTV">Watch Lichess TV</string>