change arg name and prefix locales

This commit is contained in:
Fijxu 2025-03-26 22:39:52 -03:00
parent 0c83eb2c39
commit a1a66e064c
No known key found for this signature in database
GPG Key ID: 32C1DDF333EDA6A4
5 changed files with 16 additions and 16 deletions

View File

@ -502,10 +502,10 @@
"carousel_slide": "Slide {{current}} of {{total}}",
"carousel_skip": "Skip the Carousel",
"carousel_go_to": "Go to slide `x`",
"new_username": "New username",
"change_username": "Change username",
"username_required_field": "Username is a required field",
"username_empty": "Username cannot be empty",
"username_is_the_same": "This is your username, use another one",
"username_taken": "Username is already taken, use another one"
"accounts_new_username": "New username",
"accounts_change_username": "Change username",
"accounts_username_required_field": "Username is a required field",
"accounts_username_empty": "Username cannot be empty",
"accounts_username_is_the_same": "This is your username, use another one",
"accounts_username_taken": "Username is already taken, use another one"
}

View File

@ -184,14 +184,14 @@ module Invidious::Database::Users
PG_DB.exec(request, pass, user.email)
end
def update_username(user : User, username : String)
def update_username(user : User, new_username : String)
request = <<-SQL
UPDATE users
SET email = $1
WHERE email = $2
SQL
PG_DB.exec(request, username, user.email)
PG_DB.exec(request, new_username, user.email)
end
def update_user_session_id(user : User, username : String)

View File

@ -125,19 +125,19 @@ module Invidious::Routes::Account
new_username = env.params.body["new_username"]?.try &.downcase.byte_slice(0, 254)
if new_username.nil?
return error_template(401, "username_required_field")
return error_template(401, "accounts_username_required_field")
end
if new_username.empty?
return error_template(401, "username_empty")
return error_template(401, "accounts_username_empty")
end
if new_username == user.email
return error_template(401, "username_is_the_same")
return error_template(401, "accounts_username_is_the_same")
end
if Invidious::Database::Users.select(email: new_username)
return error_template(401, "username_taken")
return error_template(401, "accounts_username_taken")
end
Invidious::Database::Users.update_username(user, new_username.to_s)

View File

@ -1,5 +1,5 @@
<% content_for "header" do %>
<title><%= translate(locale, "change_username") %> - Invidious</title>
<title><%= translate(locale, "accounts_change_username") %> - Invidious</title>
<% end %>
<div class="pure-g">
@ -10,11 +10,11 @@
<legend><%= translate(locale, "") %></legend>
<fieldset>
<label for="new_username"><%= translate(locale, "new_username") %> :</label>
<label for="accounts_new_username"><%= translate(locale, "new_username") %> :</label>
<input required class="pure-input-1" name="new_username" type="text" placeholder="<%= translate(locale, "new_username") %>">
<button type="submit" name="action" value="change_username" class="pure-button pure-button-primary">
<%= translate(locale, "change_username") %>
<%= translate(locale, "accounts_change_username") %>
</button>
<input type="hidden" name="csrf_token" value="<%= HTML.escape(csrf_token) %>">

View File

@ -331,7 +331,7 @@
</div>
<div class="pure-control-group">
<a href="/change_username?referer=<%= URI.encode_www_form(referer) %>"><%= translate(locale, "change_username") %></a>
<a href="/change_username?referer=<%= URI.encode_www_form(referer) %>"><%= translate(locale, "accounts_change_username") %></a>
</div>
<div class="pure-control-group">