back-end/app/controllers/admin_user_controller.rb
# Request a password reset link on email\
Request a password reset link on email\
Request a password reset link on email \
def request_password_reset
    if params[:email]
      user = AdminUser.where(email: params[:email]).first
      if user
        password_reset_link = PasswordResetLink.new(user_id: user.id)
        if password_reset_link.save
          render json: {status: "success", message: "Reset mail sent"} and return
        else
          error_message = password_reset_link.errors.full_messages
        end
      else
        error_message = "User not found"
      end
    else
      error_message = "Invalid parameters"
    end
    render json: {status: "error", error_message: error_message}
  end
def request_password_reset if params [ :email ] user = AdminUser . where ( email : params [ :email ] ) . first if user password_reset_link = PasswordResetLink . new ( user_id : user . id ) if password_reset_link . save render json : { status : "success" , message : "Reset mail sent" } and return else error_message = password_reset_link . errors . full_messages end else error_message = "User not found" end else error_message = "Invalid parameters" end render json : { status : "error" , error_message : error_message } end
Request a password reset link on email\
Request a password reset link on email \
#todo: send email