Sha256: 8bb85e033fe4f34ffafeb7ecbaf4d6116fee994e92faee8a175f73bcaf375a3e
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
require_dependency "ishapi/application_controller" module Ishapi class UsersController < ApplicationController def fb_sign_in authorize! :fb_sign_in, Ishapi params.permit! access_token = params[:accessToken] email = params[:email] name = params[:name] user = User.where( :email => email ).first u = IshModels::UserProfile.find_or_create_by :email => email u.fb_access_token = access_token u.name ||= name u.user = user u.user ||= User.create( :email => email, :password => (0..8).map { "#{rand(100)}" }.join("#{rand(100)}") ) if u.save render :json => { :status => :ok } else render :json => { :status => :not_ok, :errors => u.errors.messages } end end def show authorize! :fb_sign_in, Ishapi @graph = Koala::Facebook::API.new( params[:accessToken] ) me = @graph.get_object( 'me', :fields => 'email' ) @user = User.find_by( :email => me['email'] ) @user_profile = IshModels::UserProfile.find_by :email => me['email'] end def update authorize! :fb_sign_in, Ishapi @graph = Koala::Facebook::API.new( params[:accessToken] ) me = @graph.get_object( 'me', :fields => 'email' ) @user = User.find_by( :email => me['email'] ) @user_profile = IshModels::UserProfile.find_by :email => me['email'] flag = @user_profile.update_attributes( params[:user_profile].permit( :about, :current_city_id ) ) if flag render :json => { :status => :ok } else render :json => { :status => :not_ok, :errors => @user_profile.errors.messages } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ishapi-0.1.8.16 | app/controllers/ishapi/users_controller.rb |
ishapi-0.1.8.15 | app/controllers/ishapi/users_controller.rb |