Skip to content

Commit

Permalink
login redirect and save user on local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
bukinoshita committed Feb 13, 2018
1 parent 76de148 commit f9c08b6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions renderer/pages/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Packages
import { Component } from 'react'
import Link from 'next/link'
import Router from 'next/router'

// Layouts
import Page from './../layouts/page'
Expand All @@ -15,6 +16,8 @@ import ButtonLink from './../ui/button-link'

// Services
import api from './../services/api'
import { setCookie } from './../services/cookies'
import { getUser, updateUser } from './../services/local-storage'

// Theme
import { colors, typography } from './../theme'
Expand Down Expand Up @@ -49,6 +52,22 @@ class Login extends Component {
password
})
.then(res => {
if (res.token) {
const { email, name, username, subscription } = res.user
const { user } = getUser()

setCookie(res.token)

user.token = res.token
user.email = email
user.name = name
user.username = username
user.subscription = subscription

updateUser(user)

return Router.push('/home?tab=Today')
}
console.log(res)
})
.catch(err => {
Expand Down

0 comments on commit f9c08b6

Please sign in to comment.