No commit activity in last 3 years
No release in over 3 years
Ember-auth rememberable module source code wrapper for ruby libs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

rememberable module for ember-auth

Build Status Gem Version NPM version

"Remember me" feature for ember-auth.

Config

App.Auth = Em.Auth.extend
  modules: ['rememberable']

  rememberable:
    # [string] key for the remember token in server requests and payloads
    tokenKey: null

    # [number] (opt) valid period (days) for the remember token;
    #   default: 14
    period: 14

    # [bool] (opt) whether to auto-recall a remembered session;
    #   default: true
    autoRecall: true

    # [string|null] (opt) a different end point for sign in requests
    #   from rememberable
    endPoint: null

Usage

# call _super() and follow the promise pattern
# if you override Ember.Route.beforeModel()
App.FooRoute = Ember.Route.extend
  beforeModel: ->
    @_super.apply(this, arguments).then -> doSomething()
  # or
  beforeModel: ->
    doSomething()
    @_super.apply(this, arguments) # already returns promise
# low level methods for manual use

# try to recall a remembered session, if any
#
# @param opts [object] (opt) jquery.ajax(settings) -style options object,
#   default: {}
#
# @return [Em.RSVP.Promise]
#   if there is no active signed in session,
#     and if a remembered session is found,
#     returns the auth.signIn() promise;
#   else returns a resolved empty promise
@auth.get('module.rememberable').recall(opts)

# clear any existing remembered session,
# then extract any rememberable session info from sign in payload
#
# @param data [object] the `canonicalize`d data object
@auth.get('module.rememberable').remember(data)

# clear any existing remembered session
@auth.get('module.rememberable').forget()

License

MIT