Skip to content

Commit 038b498

Browse files
committed
Updated user
1 parent 92ccacc commit 038b498

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class ApplicationController < ActionController::Base
22
# Prevent CSRF attacks by raising an exception.
33
# For APIs, you may want to use :null_session instead.
4-
protect_from_forgery with: :null_session
4+
protect_from_forgery with: :exception
55

66
helper_method :current_user
77

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
class DashboardController < ApplicationController
22
def show
3-
if current_user == nil
4-
current_user
5-
else
6-
@current_user if current_user
7-
@user_info ||= UserPresenter.new(current_user)
8-
end
3+
@current_user
4+
@user_info ||= UserPresenter.new(current_user)
95
end
106
end

app/models/user.rb

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
class User < ActiveRecord::Base
2+
23
def self.find_or_create_from_oauth(oauth)
34
user = User.find_or_create_by(provider: oauth.provider, uid: oauth.uid)
4-
5-
user.update_attributes(
6-
7-
email: oauth.info.email,
8-
nickname: oauth.info.nickname,
9-
image_url: oauth.info.image,
10-
token: oauth.credentials.token,
11-
repos: GithubPresenter.new(user).repos,
12-
starred_repos: GithubPresenter.new(user).starred_repos,
13-
organizations: GithubPresenter.new(user).organizations,
14-
commit_messages: GithubPresenter.new(user).commit,
15-
followers: GithubPresenter.new(user).followers,
16-
followees: GithubPresenter.new(user).followees,
17-
total_commits: GithubPresenter.new(user).year_commits,
18-
current_streak: GithubPresenter.new(user).current_streaks,
19-
longest_streak: GithubPresenter.new(user).longest_streaks,
20-
follower_messages: GithubPresenter.new(user).followers_activities,
21-
22-
)
5+
user.email = oauth.info.email
6+
user.nickname = oauth.info.nickname
7+
user.image_url = oauth.info.image
8+
user.token = oauth.credentials.token
9+
user.repos = GithubPresenter.new(user).repos
10+
user.starred_repos = GithubPresenter.new(user).starred_repos
11+
user.organizations = GithubPresenter.new(user).organizations
12+
user.commit_messages = GithubPresenter.new(user).commit
13+
user.followers = GithubPresenter.new(user).followers
14+
user.followees = GithubPresenter.new(user).followees
15+
user.total_commits = GithubPresenter.new(user).year_commits
16+
user.current_streak = GithubPresenter.new(user).current_streaks
17+
user.longest_streak = GithubPresenter.new(user).longest_streaks
18+
user.follower_messages = GithubPresenter.new(user).followers_activities
19+
user.save
2320

2421
user
2522
end

0 commit comments

Comments
 (0)