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); }); };