Method: Fortifier::AuthUserApi#link

Defined in:
app/models/fortifier/auth_user_api.rb


252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'app/models/fortifier/auth_user_api.rb', line 252

def link(params)
  return {status: false, errors: [:uuid_not_provided]} if params[:uuid].blank?

  app_uuids       = params[:app_uuids] || []
     = params[:account_uuids] || []
  search_keywords = params[:search_keywords] || []
  return {status: false, errors: [:app_and_account_uuids_not_provided]} if (app_uuids.blank? && .blank?)

  auth_user = AuthUser.where(uuid: params[:uuid]).first
  return {status: false, errors: [:auth_user_not_found]} if auth_user.blank?

  auth_user.app_uuids.concat(app_uuids)
  auth_user..concat()
  auth_user.search_keywords.concat(search_keywords)
  result = auth_user.save

  result ? {status: true} : {status: false, errors: (result.errors.full_messages if result)}
end