Git Product home page Git Product logo

Comments (2)

adamniedzielski avatar adamniedzielski commented on June 28, 2024

This method is defined here - https://github.com/plataformatec/devise/blob/342304375946ca11608516eae80f78dbaae059d5/app/controllers/devise/sessions_controller.rb#L59

It will be run before our destroy action, because we inherit from Devise::SessionsController. I believe that it will say that there is no signed in user and prevent our destroy action from running at all. That's why we just override it with an empty method.

I encourage you to check out what happens if you remove it. I think that the token will be not removed.

from tiddle.

zulhfreelancer avatar zulhfreelancer commented on June 28, 2024

Ok thanks. Btw, how to handle a situation where a user want to change his/her password?

Say, I've an AngularJS app as the client and I have a page called Change password inside the app.

Can you give some example?

Currently, I have this:

class Users::RegistrationsController < Devise::RegistrationsController
  def update
    respond_to do |format|
      format.html {super}
      format.json {
        # also required X-USER-EMAIL and X-USER-TOKEN inside the headers
        email = params[:user][:email] # might send a hidden field for this email
        user  = User.find_by_email(email)
        if params[:user][:password] == params[:user][:password_confirmation]
          if user.update(password: params[:user][:password])
            render json: {status: "Success", message: "Password changed"}
          else
            render json: {status: "Error", message: "Password not changed"}
          end
        else
          render json: {status: "Error", message: "Password not matched"}
        end
      }
    end
  end
end

Do you have better idea?

Thanks!

from tiddle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.