|
1 | 1 | class User < ActiveRecord::Base |
| 2 | + |
2 | 3 | def self.find_or_create_from_oauth(oauth) |
3 | 4 | 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 |
23 | 20 |
|
24 | 21 | user |
25 | 22 | end |
|
0 commit comments