senecajs / seneca-auth

A Seneca user authentication plugin for Hapi and Express
http://senecajs.org
MIT License
33 stars 29 forks source link

seneca auth not redirecting in Hapi #77

Closed nicholaschantcs closed 8 years ago

nicholaschantcs commented 8 years ago

Hi, I am trying to get the redirects working in Hapi but it seemed to return me the callback rather than the http redirect and the URL is showing localhost:10000/auth/login

{"http$":{"status":301,"redirect":"/"}}

options.js

module.exports = { 
      secure: true,
      restrict: '/api',
      server: 'hapi',
      strategies: [
        {
          provider: 'local'
        }
      ],
    redirect:{
      always: true,
      win:'/',
      fail:'/',
      restrict:'/',

      login:         {win:'/',fail:'/#',},
      logout:        {win:'/login',fail:'/#',},
      register:      {win:'/login',fail:'/#',},
      reset_create:  {win:'/',fail:'/',},
      reset_load:    {win:'/',fail:'/',},
      reset_execute: {win:'/',fail:'/',},
      confirm:       {win:'/',fail:'/',},
    }
}

Am I doing it wrongly? I supposed it should be the similar approach with using Express but it's seemed more complicated than I thought.

mirceaalexandru commented 8 years ago

@nicholaschantcs

What you are doing is correct, but not sufficient in this moment because not all dependent modules are published yet:

So, for now, until we have all modules published you should use something like this:

var plugins = [
  {register: Bell},
  {register: Cookie},
  {register: Chairo, options: {
     web: require('seneca-web')
  } },
.......
]

server.register(plugins, function (err) {

and in your package.json:

  "seneca-web": "0.7.1"

This will force using latest seneca-web that knows how to redirect.

Let me know if it is OK.

nicholaschantcs commented 8 years ago

Thanks @mirceaalexandru

The alternative approach that you suggested works fine . Oh, I can picture it now. Until the dependent modules are published, I suppose for now I need to explicitly use the latest options for the web.

mirceaalexandru commented 8 years ago

@nicholaschantcs Great!

You can close the issue if it is OK with you. Hopefully all dependent modules will be published soon.

mirceaalexandru commented 8 years ago

@nicholaschantcs BTW, really soon a seneca-auth with support for Hapi will be available, now you can see that version on

mirceaalexandru commented 8 years ago

@nicholaschantcs BTW, the strategies (and server) parameters are not longer required as in the last version the local strategy is loaded by default.

I just changed the example from Readme.

nicholaschantcs commented 8 years ago

@mirceaalexandru :+1: Alright, thanks for the heads up.