ExpressJS / Node ajax login

Hi I am using express framework to make site in node. I am trying to use facebox to represent a window in which use can be logged in so that the music on the site should not stop.

I use mongoose-auth / everyauth for authentication and cannot figure out how to do this.

I need to make the login page as partial, I think. I have the following: I think using loginLocals is the answer?

Does anyone have any ideas!?

var mongoose = require('mongoose') , Schema = mongoose.Schema , mongooseAuth = require('mongoose-auth'); var everyauth = require('everyauth') , Promise = everyauth.Promise; var UserSchema = new Schema({}); UserSchema.plugin(mongooseAuth, { everymodule: { everyauth: { User: function () { return User; } } }, password: { loginWith: 'email' , extraParams: { genre: String } , everyauth: { getLoginPath: '/login' , postLoginPath: '/login' , loginView: 'login.jade' , getRegisterPath: '/register' , postRegisterPath: '/register' , registerView: 'register.jade' , loginSuccessRedirect: '/' , registerSuccessRedirect: '/' , loginLocals: function(req, res) { //console.log("ASD"); return res.partial('toop'); } } } }); 
+4
source share
1 answer

If you want your users to be able to register through Everyauth without stopping the music, you cannot do this with lightboxes like facebox. You need AJAX for your page to load (and therefore your music played), but OAuth does not work on AJAX because it uses redirects.

You need to do something like this:

  • When the user clicks on the login on page "A", open a new pop-up window "B" indicating your login process.
  • Everyauth redirects window "B" to the appropriate OAuth provider.
  • User will authenticate and grant permissions
  • Window "B" will be redirected to your site.
  • You need to choose the end of the process, and from the pop-up window "B" you need to contact the window "A", which the user has successfully completed. You can do this directly using Javascript or tell the server the source page (via websites, comet, survey, etc.).
  • Your music will play all the time in window "A"
+1
source

Source: https://habr.com/ru/post/1386790/


All Articles