Sha256: c949456c869ba0d45a2c53ead627c2a48e6c725e427e889849ebd2242bf873e8
Contents?: true
Size: 953 Bytes
Versions: 9
Compression:
Stored size: 953 Bytes
Contents
module ApiUserAuth # Auth user helper module AuthUserHelper extend ActiveSupport::Concern # Class methods module ClassMethods def create_by_params(params) email_exception if params[:email].blank? password_exception if params[:password].blank? auth_user = AuthUser.find_or_initialize_by(email: params[:email]) if auth_user.new_record? auth_user.is_new = true auth_user.update_password(params[:password]) else user_exist_exception end auth_user end private def email_exception raise Exceptions::WrongParams, I18n.t('api_user_auth.errors.email') end def password_exception raise Exceptions::WrongParams, I18n.t('api_user_auth.errors.password') end def user_exist_exception raise Exceptions::WrongParams, I18n.t('api_user_auth.errors.user_exist') end end end end
Version data entries
9 entries across 9 versions & 1 rubygems