app/controllers/api/v1/users_controller.rb
# creating a user with information passed from droplet-web frontend
creating a user with information passed from droplet-web frontend
creating a user with information passed from droplet - web frontend
def create
    credentials = user_hash(params[:body])
    user_email = credentials[:email]
    user_email.chomp.downcase!
    user = User.new(email: user_email)
    user.password = credentials[:password]
    user.save
    user.preference_setting = PreferenceSetting.create
    if user.save
      jwt = Auth.encrypt({id: user.id})
      render json: { current: user, preferences: user.preference_setting.id, jwt: jwt }
    else
      render json: { error: user.errors.full_messages.uniq }, status: 400
    end
  end
def create credentials = user_hash ( params [ :body ] ) user_email = credentials [ :email ] user_email . chomp . downcase! user = User . new ( email : user_email ) user . password = credentials [ :password ] user . save user . preference_setting = PreferenceSetting . create if user . save jwt = Auth . encrypt ( { id : user . id } ) render json : { current : user , preferences : user . preference_setting . id , jwt : jwt } else render json : { error : user . errors . full_messages . uniq } , status : 400 end end
creating a user with information passed from droplet-web frontend
creating a user with information passed from droplet - web frontend
# establish hash from frontend and sanitize data # create JWT token for authorization checks