diff --git a/locales/en-US.json b/locales/en-US.json index 44d4c5ef..2baf3408 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -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" } diff --git a/src/invidious/database/users.cr b/src/invidious/database/users.cr index bf54a321..a750bc5e 100644 --- a/src/invidious/database/users.cr +++ b/src/invidious/database/users.cr @@ -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) diff --git a/src/invidious/routes/account.cr b/src/invidious/routes/account.cr index 4eff5e1d..647e594c 100644 --- a/src/invidious/routes/account.cr +++ b/src/invidious/routes/account.cr @@ -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) diff --git a/src/invidious/views/user/change_username.ecr b/src/invidious/views/user/change_username.ecr index 85af79e6..ed7d4cc1 100644 --- a/src/invidious/views/user/change_username.ecr +++ b/src/invidious/views/user/change_username.ecr @@ -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) %>"> diff --git a/src/invidious/views/user/preferences.ecr b/src/invidious/views/user/preferences.ecr index 5cea8164..d88177ca 100644 --- a/src/invidious/views/user/preferences.ecr +++ b/src/invidious/views/user/preferences.ecr @@ -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">