Skip to content

Commit

Permalink
onboard cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bukinoshita committed Feb 13, 2018
1 parent 1689267 commit e1becef
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
},
"dependencies": {
"app-root-path": "^2.0.1",
"axios": "^0.17.1",
"classnames": "^2.2.5",
"electron-is-dev": "^0.3.0",
"electron-next": "^3.1.3",
"fs-extra": "^5.0.0",
"path-exists": "^3.0.0",
"prop-types": "^15.6.0",
"react-cookies": "^0.1.0",
"react-hash-avatar": "^0.0.2",
"react-render-html": "^0.6.0",
"react-sortable-hoc": "^0.6.8",
Expand Down
8 changes: 6 additions & 2 deletions renderer/pages/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import Page from './../layouts/page'
// Components
import Row from './../components/row'

// Services
import { getCookie } from './../services/cookies'

// Theme
import { colors, typography } from './../theme'

class Start extends Component {
componentDidMount() {
const isPro = remote && remote.app ? remote.app.config.user.pro : false
const redirectUrl = isPro ? '/login' : '/onboard'
const cfg = remote && remote.app ? remote.app.config : {}
const token = getCookie('taskr')
const redirectUrl = cfg.user.pro && token ? '/home?tab=Today' : '/onboard'

Router.push(redirectUrl)
}
Expand Down
2 changes: 1 addition & 1 deletion renderer/services/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

// Packages
const uid = require('uid-promise')
import uid from 'uid-promise'

export const getUser = () => {
const storage = JSON.parse(localStorage.getItem('taskr'))
Expand Down
21 changes: 21 additions & 0 deletions renderer/services/cookies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'

import cookie from 'react-cookies'

export const getCookie = key => {
return cookie.load(key)
}

export const setCookie = value => {
const now = new Date()
now.setDate(now.getDate() + 14)

return cookie.save('taskr', value, {
expires: now,
path: '/'
})
}

export const logout = () => {
return cookie.remove('taskr', { path: '/' })
}
24 changes: 24 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,13 @@ aws4@^1.2.1, aws4@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"

axios@^0.17.1:
version "0.17.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.17.1.tgz#2d8e3e5d0bdbd7327f91bc814f5c57660f81824d"
dependencies:
follow-redirects "^1.2.5"
is-buffer "^1.1.5"

babel-code-frame@^6.16.0, babel-code-frame@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
Expand Down Expand Up @@ -1606,6 +1613,10 @@ convert-source-map@1.5.1, convert-source-map@^1.5.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5"

cookie@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"

core-assert@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/core-assert/-/core-assert-0.2.1.tgz#f85e2cf9bfed28f773cc8b3fa5c5b69bdc02fe3f"
Expand Down Expand Up @@ -2666,6 +2677,12 @@ follow-redirects@1.2.6:
dependencies:
debug "^3.1.0"

follow-redirects@^1.2.5:
version "1.3.0"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.3.0.tgz#f684871fc116d2e329fda55ef67687f4fabc905c"
dependencies:
debug "^3.1.0"

for-in@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
Expand Down Expand Up @@ -5206,6 +5223,13 @@ react-attr-converter@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/react-attr-converter/-/react-attr-converter-0.3.1.tgz#4a2abf6d907b7ddae4d862dfec80e489ce41ad6e"

react-cookies@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/react-cookies/-/react-cookies-0.1.0.tgz#6bb883f2d1a397f138a4110300b46fe25df8f1a9"
dependencies:
cookie "^0.3.1"
object-assign "^4.1.1"

react-deep-force-update@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-2.1.1.tgz#8ea4263cd6455a050b37445b3f08fd839d86e909"
Expand Down

0 comments on commit e1becef

Please sign in to comment.