Method: MailserviceController#user_change_password

Defined in:
app/controllers/mailservice_controller.rb

#user_change_password(old_password, password, password_confirmation) ⇒ Object

Lets the user change his password.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'app/controllers/mailservice_controller.rb', line 316

def user_change_password(old_password, password, password_confirmation)
    user_logged_in?
    user=User.find(session[:user_id])
    if User.authenticate(user., old_password) then
        user.password=password
        user.password_confirmation=password_confirmation
        if(user.save)
            return true
        else
            errstr = user.errors.sort.map do |fac,err| 
                "#{fac}: #{err}" 
            end.join("\n")

            raise RuntimeError, errstr
        end
    else
        raise "auth: original password incorrect"
    end
end