base-repository
Version:
[](https://travis-ci.org/joehua87/base-repository)
41 lines (33 loc) • 884 B
JavaScript
/*
import jwt from 'koa-jwt'
const debug = require('debug')('redux-universal:api:controller:auth')
const defaultAuthOptions = {
read: ['read'],
manipulate: ['manipulate']
}
export function createAuthenticateController(secret, authOptions = defaultAuthOptions) {
}
type User = {
username: String,
password: String,
scopes: Array<String>
}
export function createGetTokenController(secret:String, users) {
return function* auth() {
const { username, password } = this.request.body
if (!username) this.throw(400, 'Require username')
if (!password) this.throw(400, 'Require password')
if (username !== 'admin') {
this.throw(400, 'Account is not exists')
}
if (password !== '123456') {
this.throw(400, 'Invalid password')
}
const token = jwt.sign({ username, password }, secret)
debug(token)
this.status = 200
this.body = { token }
}
}
*/
"use strict";