Skip to content

Commit 84c40e5

Browse files
committed
Change email, change password, and email only appear on a user's page if logged in as that user. Anyone can visit a user's page. Added links to user's pages on home page.
1 parent 72c84a7 commit 84c40e5

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

app/controllers/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class UsersController < ApplicationController
2-
before_action :authorized, only: [:show]
2+
before_action :authorized, only: []
33
def new
44
@user = User.new
55
end

app/views/articles/index.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<ul>
55
<% @articles.each do |article| %>
66
<li>
7-
<%= link_to article.title, article.link %> - Posted by <%= article.user.name %> on <%= article.created_at.strftime("%B %d, %Y at %I:%M %p") %>
7+
<%= link_to article.title, article.link %> - Posted by <%= link_to article.user.name, article.user %> on <%= article.created_at.strftime("%B %d, %Y at %I:%M %p") %>
88
<div>
99
<%= link_to "comment", article %>
1010
</div>
1111
</li>
1212
<% end %>
1313
</ul>
1414

15-
<%= paginate @articles %>
15+
<%= paginate @articles %>

app/views/users/show.html.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<h1><%= user.name %></h1>
2-
<p>Email: <%= user.email %></p>
3-
<%= button_to "Change Email", edit_email_user_path(user), method: :get %>
4-
<%= button_to "Change Password", edit_password_user_path(user), method: :get %>
2+
<% if user == current_user %>
3+
<p>Email: <%= user.email %></p>
4+
<%= button_to "Change Email", edit_email_user_path(user), method: :get %>
5+
<%= button_to "Change Password", edit_password_user_path(user), method: :get %>
6+
<% end %>

0 commit comments

Comments
 (0)