Class: Auth::PasswordsController

Inherits:
BaseController show all
Defined in:
app/controllers/auth/passwords_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#devise_mapping

Instance Method Details

#createObject

POST /resource/password



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/auth/passwords_controller.rb', line 15

def create
  self.resource = Auth::PasswordNewForm.new(params[resource_name])

  # if successfully_sent?(resource)
  if resource.submit
    flash[:notification] = 'auth.new_password.succes'
    respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
  else
    respond_with(resource)
  end
end

#editObject

GET /resource/password/edit?reset_password_token=abcdef



42
43
44
45
# File 'app/controllers/auth/passwords_controller.rb', line 42

def edit
  self.resource = resource_class.new
  resource.reset_password_token = params[:reset_password_token]
end

#newObject

GET /auth/password/new



10
11
12
# File 'app/controllers/auth/passwords_controller.rb', line 10

def new
  self.resource = Auth::PasswordNewForm.new
end

#send_reset_passObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/auth/passwords_controller.rb', line 27

def send_reset_pass
  self.resource = Auth::PasswordNewForm.new(params[resource_name])
  respond_to do |format|
    format.json do
      if resource.submit
        render json: resource.to_json
      else
        render json: { errors: resource.errors }.to_json, status: :unprocessable_entity
      end
    end
    format.all { render_404 }
  end
end

#sentObject

GET /resource/password/sent



67
68
69
# File 'app/controllers/auth/passwords_controller.rb', line 67

def sent
  @structure = ContentStorageType.password_sent.storage
end

#updateObject

PUT /resource/password



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/auth/passwords_controller.rb', line 48

def update
  self.resource = resource_class.reset_password_by_token(resource_params)
  if resource&.errors&.empty?
    resource.unlock_access! if unlockable?(resource)
    if is_navigational_format?
      set_flash_message(
        :notice, resource.active_for_authentication? ? :updated : :updated_not_active
      )
    end
    (resource_name, resource)

    respond_with resource, location: after_resetting_password_path_for(resource)
  else
    # resource.reset_password_token = resource_params[:reset_password_token]
    respond_with resource
  end
end