From 58cda9cc7fb79ca9df6746de7f9662bc08dc156a Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 13 Oct 2017 12:29:40 +0200 Subject: initial commit --- src/api/UserApi.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/api/UserApi.js (limited to 'src/api/UserApi.js') diff --git a/src/api/UserApi.js b/src/api/UserApi.js new file mode 100644 index 000000000..e8fd75bed --- /dev/null +++ b/src/api/UserApi.js @@ -0,0 +1,49 @@ +import { hash } from '../helpers/password-helpers'; + +export default class UserApi { + constructor(server, local) { + this.server = server; + this.local = local; + } + + login(email, password) { + return this.server.login(email, hash(password)); + } + + logout() { + return this; + } + + signup(data) { + Object.assign(data, { + password: hash(data.password), + }); + return this.server.signup(data); + } + + password(email) { + return this.server.retrievePassword(email); + } + + invite(data) { + return this.server.inviteUser(data); + } + + getInfo() { + return this.server.userInfo(); + } + + updateInfo(data) { + const userData = data; + if (userData.oldPassword && userData.newPassword) { + userData.oldPassword = hash(userData.oldPassword); + userData.newPassword = hash(userData.newPassword); + } + + return this.server.updateUserInfo(userData); + } + + getLegacyServices() { + return this.server.getLegacyServices(); + } +} -- cgit v1.2.3-70-g09d2