Class: UserCredentialsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #api_authenticate!, #current_project, #expire_revision!, #followed_projects, #no_cache, #read_revision, #require_login, #return_or_cache_revision!, #revision, #unfurling?, #with_current_project

Methods included from UrlHelper

#feature_path, #link_to_project_feature

Instance Method Details

#destroyObject



15
16
17
18
19
20
21
22
# File 'app/controllers/user_credentials_controller.rb', line 15

def destroy
  credentials = current_user.credentials.find_by_id(params[:id])
  if credentials && credentials.delete
    redirect_to :back, notice: "Houston has deleted your credentials for #{credentials.service}"
  else
    redirect_to :back
  end
end

#upsertObject



3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/user_credentials_controller.rb', line 3

def upsert
  credentials = current_user.credentials.where(service: params[:service]).first_or_initialize
  credentials. = params[:login]
  credentials.password = params[:password]

  if credentials.save
    head :ok
  else
    render json: credentials.errors, status: :unprocessable_entity
  end
end