2021-06-01 07:09:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2021-04-23 08:29:02 +00:00
|
|
|
class UsersController < ApplicationController
|
2021-04-29 06:41:23 +00:00
|
|
|
skip_before_action :authenticate_request
|
2021-04-23 08:29:02 +00:00
|
|
|
|
2021-04-29 06:41:23 +00:00
|
|
|
def set_password_from_token
|
|
|
|
|
user = User.where(invitation_token: params[:token]).first
|
|
|
|
|
|
|
|
|
|
if user
|
2021-05-20 10:16:21 +00:00
|
|
|
user.update(first_name: params[:first_name], last_name: params[:last_name], password: params[:password], invitation_token: nil)
|
2021-06-01 07:09:07 +00:00
|
|
|
user.organization_users.first.update(status: "active")
|
2021-05-17 11:23:11 +00:00
|
|
|
|
|
|
|
|
if params[:new_signup]
|
|
|
|
|
user.organization.update(name: params[:organization])
|
|
|
|
|
end
|
2021-04-29 06:41:23 +00:00
|
|
|
else
|
2021-06-01 07:09:07 +00:00
|
|
|
render json: { message: "Invalid Invitation Token" }, status: :bad_request
|
2021-04-23 08:29:02 +00:00
|
|
|
end
|
2021-04-29 06:41:23 +00:00
|
|
|
end
|
2021-04-23 08:29:02 +00:00
|
|
|
end
|