nfp_sites/app/login/logout.js

31 lines
713 B
JavaScript
Raw Normal View History

2019-02-20 16:10:37 +00:00
const m = require('mithril')
const Authentication = require('../authentication')
const Logout = {
oninit: function() {
Authentication.createGoogleScript()
.then(function() {
return new Promise(function (res) {
gapi.load('auth2', res)
2019-02-20 16:10:37 +00:00
})
})
.then(function() { return gapi.auth2.init() })
.then(function() {
let auth2 = gapi.auth2.getAuthInstance()
2019-02-20 16:10:37 +00:00
return auth2.signOut()
})
.then(function() {
Authentication.clearToken()
m.route.set('/')
2019-09-13 13:33:10 +00:00
}, function(err) {
console.log('unable to logout:', err)
2019-02-20 16:10:37 +00:00
})
},
view: function() {
return m('div.loading-spinner')
},
}
module.exports = Logout