From 505bb48f8bfd79fafc03a3b01780cd578da08cf2 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Fri, 10 Aug 2018 17:19:07 +0200 Subject: [PATCH] Add rest endpoints --- src/core/client/framework/rest/index.ts | 2 ++ src/core/client/framework/rest/signIn.ts | 13 +++++++++++++ src/core/client/framework/rest/signUp.ts | 14 ++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 src/core/client/framework/rest/index.ts create mode 100644 src/core/client/framework/rest/signIn.ts create mode 100644 src/core/client/framework/rest/signUp.ts diff --git a/src/core/client/framework/rest/index.ts b/src/core/client/framework/rest/index.ts new file mode 100644 index 000000000..0b3032bb5 --- /dev/null +++ b/src/core/client/framework/rest/index.ts @@ -0,0 +1,2 @@ +export { default as signIn, SignInInput } from "./signIn"; +export { default as signUp, SignUpInput } from "./signUp"; diff --git a/src/core/client/framework/rest/signIn.ts b/src/core/client/framework/rest/signIn.ts new file mode 100644 index 000000000..4b537b01c --- /dev/null +++ b/src/core/client/framework/rest/signIn.ts @@ -0,0 +1,13 @@ +import { RestClient } from "../lib/rest"; + +export interface SignInInput { + username: string; + password: string; +} + +export default function signIn(rest: RestClient, input: SignInInput) { + return rest.fetch("/tenant/auth/local", { + method: "POST", + body: input, + }); +} diff --git a/src/core/client/framework/rest/signUp.ts b/src/core/client/framework/rest/signUp.ts new file mode 100644 index 000000000..eece6271b --- /dev/null +++ b/src/core/client/framework/rest/signUp.ts @@ -0,0 +1,14 @@ +import { RestClient } from "../lib/rest"; + +export interface SignUpInput { + username: string; + password: string; + email: string; +} + +export default function signUp(rest: RestClient, input: SignUpInput) { + return rest.fetch("/tenant/auth/local/signup", { + method: "POST", + body: input, + }); +}