feathersjs-ecosystem / feathers-localstorage

A client side service based on feathers-memory that persists to LocalStorage
MIT License
38 stars 15 forks source link

usage with feathersjs authentication module on react-native #16

Closed ramsestom closed 8 years ago

ramsestom commented 8 years ago

Hi

How could I use AsyncStorage with the feathersjs authentication service on react-native. I used to do:

this.app = feathers()
      .configure(socketio(socket))
      .configure(hooks())
      // Use AsyncStorage to store our login toke
      .configure(authentication({
        storage: AsyncStorage
      }));
  }

but it doesn't work anymore with RN 0.30 and latest feathers client api

I tried

import localstorage from 'feathers-localstorage';
this.app = feathers()
      .configure(socketio(socket))
      .configure(hooks())
      .use('/auth', localstorage({ storage: AsyncStorage }));

but it doesn't work either (return an error: _this2.app.authenticate is not a function)

daffl commented 8 years ago

feathers-localstorage is a service wrapper for Async- or Localstorage and not used in the authentication module (anymore). Are you getting any errors using

const app = feathers()
      .configure(socketio(socket))
      .configure(hooks())
      // Use AsyncStorage to store our login toke
      .configure(authentication({
        storage: AsyncStorage
      }));

How are you using this setup?

ramsestom commented 8 years ago

No I don't get any error using this. But it doesn't seem to work anymore as the authentication is not stored (I have to re-authenticate each time I restart the app whereas with previous version of react native it was working as expected and the authentication token was correctly stored)

EDIT:I traced back the error and it was a wrong routing in my app (forgot to change the name of an action). So the authentication AsyncStorage is working as expected. Sorry