main
rb 25 lines 820 Bytes
Raw
1 # frozen_string_literal: true
2
3 module Api
4 module V1
5 # Request password-reset instructions for an account.
6 class PasswordsController < Api::BaseController
7 # POST /api/v1/auth/password/reset
8 # Params: email
9 #
10 # The underlying endpoint always responds the same way regardless of
11 # whether the account exists (no enumeration), and calling it again
12 # re-issues the token, so it also serves the desktop "resend reset
13 # instructions" flow. Returns 204 on success.
14 def create
15 email = params[:email].to_s.strip.downcase
16 if email.blank?
17 return render_error(ERR_INVALID, "Email is required.", status: :unprocessable_entity)
18 end
19
20 SmbcloudAuthService.reset_password(email: email)
21 head :no_content
22 end
23 end
24 end
25 end