1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-20 21:21:59 +00:00

refactor Actions & add logout action

This commit is contained in:
Rokt33r
2015-07-14 01:20:17 +09:00
parent b0d9895e5e
commit 8b10eb130a
19 changed files with 69 additions and 94 deletions

View File

@@ -2,13 +2,13 @@
var Reflux = require('reflux')
var request = require('superagent')
var login = require('../Actions/login')
var register = require('../Actions/register')
var AuthActions = require('../Actions/AuthActions')
var AuthStore = Reflux.createStore({
init: function () {
this.listenTo(login, this.login)
this.listenTo(register, this.register)
this.listenTo(AuthActions.login, this.login)
this.listenTo(AuthActions.register, this.register)
this.listenTo(AuthActions.logout, this.logout)
},
// Reflux Store
login: function (input) {
@@ -49,6 +49,12 @@ var AuthStore = Reflux.createStore({
this.trigger(user)
}.bind(this))
},
logout: function () {
localStorage.removeItem('token')
localStorage.removeItem('user')
this.trigger()
},
// Methods
check: function () {
if (localStorage.getItem('token')) return true