upto 3.16

This commit is contained in:
Aaro Koivukangas
2023-08-14 17:57:21 +03:00
parent e5f040e583
commit 86e46cb954
2 changed files with 7 additions and 9 deletions
+1 -5
View File
@@ -39,13 +39,9 @@ class UsersController < ApplicationController
# PATCH/PUT /users/1 or /users/1.json # PATCH/PUT /users/1 or /users/1.json
def update def update
if not @user == current_user
redirect_to user_path(@user), notice: "User not authorized to edit this user"
return
end
respond_to do |format| respond_to do |format|
if @user.update(user_params) if user_params[:username].nil? && @user == current_user && @user.update(user_params)
format.html { redirect_to user_url(@user), notice: "User was successfully updated." } format.html { redirect_to user_url(@user), notice: "User was successfully updated." }
format.json { render :show, status: :ok, location: @user } format.json { render :show, status: :ok, location: @user }
else else
+6 -4
View File
@@ -13,10 +13,12 @@
</div> </div>
<% end %> <% end %>
<div> <% if @user.new_record? %>
<%= form.label :username, style: "display: block" %> <div>
<%= form.text_field :username %> <%= form.label :username, style: "display: block" %>
</div> <%= form.text_field :username %>
</div>
<% end %>
<div> <div>
<%= form.label :password, style: "display: block" %> <%= form.label :password, style: "display: block" %>