From b3abb588e296fdc3a8f9d656b888680e1178bf47 Mon Sep 17 00:00:00 2001 From: Simona Peneva Date: Wed, 9 Feb 2022 13:38:09 +0200 Subject: [PATCH] Use oauth for login --- examples/login.html | 63 +++++++++++++++++++++++-------------- src/client/methods/login.js | 20 ++++++------ 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/examples/login.html b/examples/login.html index ec55a1e..f21be92 100644 --- a/examples/login.html +++ b/examples/login.html @@ -1,4 +1,5 @@ + pCloud SDK: Examples / List folder +
-
-
- - -
+
- + + \ No newline at end of file diff --git a/src/client/methods/login.js b/src/client/methods/login.js index cb7e011..da837e7 100644 --- a/src/client/methods/login.js +++ b/src/client/methods/login.js @@ -1,20 +1,18 @@ /* @flow */ -import invariant from "invariant"; import type { MethodApi } from "../types"; -import { isEmail } from "../../utils"; - -export default ({ client, setToken }: MethodApi) => (email: string, password: string): Promise => { - invariant(typeof email === "string" && isEmail(email), "`email` must be provided."); - invariant(password, "`password` is required."); - invariant(password.length, "`password` is required."); +export default ({ client }: MethodApi) => (optionalParams?: Object): Promise => { return client .api("userinfo", { - params: { username: email, password: password, getauth: 1, logout: 1 }, + params: { + ...optionalParams, + }, + }) + .then(response => { + return response; }) - .then(({ auth }) => { - setToken(auth); - return auth; + .catch(error => { + console.log("Error", error); }); };