auth module is done

This commit is contained in:
Sukchan Lee 2017-05-19 15:08:32 +09:00
parent 0639fa2071
commit e2b789cafe
3 changed files with 16 additions and 5 deletions

12
webui/components/start.js Normal file
View File

@ -0,0 +1,12 @@
import React from 'react'
import Session from './session'
export default class extends React.Component {
// Expose session to all pages
static async getInitialProps({req}) {
const session = new Session({req})
return {session: await session.getSession(true)}
}
}

View File

@ -3,11 +3,11 @@
*/
import Link from 'next/link'
import React from 'react'
import Page from '../components/page'
import Start from '../components/start'
import Layout from '../components/layout'
import Session from '../components/session'
export default class extends Page {
export default class extends Start {
render() {
return (
<Layout session={this.props.session}>

View File

@ -59,8 +59,7 @@ export default class extends Page {
const session = new Session()
session.signin(this.state.username, this.state.password)
.then(() => {
// @FIXME next/router not working reliably so using window.location
window.location = '/'
this.props.url.push('/')
})
.catch(err => {
// @FIXME Handle error