app/controllers/ctws/users_controller.rb in ctws-0.2.3.beta vs app/controllers/ctws/users_controller.rb in ctws-0.3.0.beta
- old
+ new
@@ -1,26 +1,25 @@
module Ctws
class UsersController < CtwsController
skip_before_action :authorize_request, only: :create
-
+
# POST /signup
# return authenticated token upon signup
def create
- # We use Active Record's create! method so that in the event there's an error,
+ # We use Active Record's create! method so that in the event there's an error,
# an exception will be raised and handled in the exception handler.
ctws_user = Ctws.user_class.create!(ctws_user_params)
- if Ctws.user_validate_with_password
+ if Ctws.user_authentication_callback.present?
auth_token = Ctws::AuthenticateUser.new(ctws_user.email, ctws_user.password).call
- elsif !Ctws.user_validate_with_password
+ else
auth_token = Ctws::AuthenticateUser.new(ctws_user.email).call
end
-
json_response(ctws_user.created_as_jsonapi({"#{ctws_user.model_name.singular}": ctws_user, token: auth_token}), :created)
end
-
+
private
-
+
def ctws_user_params
params.permit(Ctws.user_class_strong_params)
end
end
-end
\ No newline at end of file
+end