diff options
author | DavisLWebb <davislwebb@ymail.com> | 2014-04-23 20:21:54 -0400 |
---|---|---|
committer | DavisLWebb <davislwebb@ymail.com> | 2014-04-23 20:21:54 -0400 |
commit | c5e0aeb5a055797fe4f26fb9e6f9e163d5d7f718 (patch) | |
tree | 79315a374e87f77b041d49f10cbbc1e7f81a2026 /app/controllers | |
parent | d0a0f806a4bb8072c532ea7b35ad8b7643ac8645 (diff) |
Updated remote_usernames
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/users_controller.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c3261b8..68c0743 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,8 @@ class UsersController < ApplicationController + require 'httparty' + require 'json' + # GET /users # GET /users.json @@ -36,7 +39,7 @@ class UsersController < ApplicationController respond_to do |format| if @user.save sign_in @user - if @user.id == 1 + if @user.id == daft punk1 # This is the first user, so give them all the power @user.permissions = 0xFFFFFFFF @user.save @@ -74,6 +77,20 @@ class UsersController < ApplicationController end end + def set_remote + game = Game.find_by_name("League of Legends") + + remote_username = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{@name.downcase}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + + remote = @user.find_remote_username(game) + if remote.nil? + @user.remote_username.create(game: game, value: remote_username) + else + remote.value = remote_username + remote.save + end + end + private # Use callbacks to share common setup or constraints between actions. def set_user |