登入流程詳解
Jun 17, 2015Preface
let user = yield r.db(‘system’)
.table(‘accounts’)
.insert({
username: username,
password: yield pbkdf2(password),
services: [
{name: serviceName, token: uuid.v4()}
]
})
yield r.dbCreate(user.generated_keys[0].replace(/-/g, ‘_’))
Signup
Register Account Form from frontend
- username
- password
- first service name
Post to Backend service
- username
- password (pbkdf2 encrypted)
- use rethinkdb account id replace - to _ as db name
- generate a service token for first service
Return Login Data to Frontend
- services with tokens (maybe not)
- Application Id ??
- current login session token (maybe jsonwebtoken)
FrontEnd need to tell me every request
- X-Meepcloud-Access-Token
- X-Meepcloud-Application-Id
eg.
url https://api.meepcloud.com/v1/Object/Products/ …
header X-Meepcloud-Access-Token X-Meepcloud-Application-Id
Login
Login for maintain token only otherwise just application with token