Class: Passportist::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/passportist/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
# File 'app/controllers/passportist/users_controller.rb', line 9

def create
  respond_with User.create(params[:user], as: :passportist), location: nil
end

#destroyObject



31
32
33
# File 'app/controllers/passportist/users_controller.rb', line 31

def destroy
  respond_with User.destroy(@user)
end

#syncObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/passportist/users_controller.rb', line 13

def sync
  params[:user].each do |user_data|
    user = User.find_or_initialize_by_uid(user_data['uid'])

    user.name = user_data['name']
    user.nickname = user_data['nickname']
    user.email = user_data['email']
    user.token = user_data['token']
    user.save!
  end

  render nothing: true
end

#updateObject



27
28
29
# File 'app/controllers/passportist/users_controller.rb', line 27

def update
  respond_with @user.update_attributes(params[:user], as: :passportist)
end