1 | import { AuthenticationDetails } from 'amazon-cognito-identity-js';
|
2 | import { _cognito_user } from './_cognito_user';
|
3 | export async function authenticateUser(Username, Password) {
|
4 | const AuthenticationDetails__ = new AuthenticationDetails({
|
5 | Username,
|
6 | Password,
|
7 | });
|
8 | const user = _cognito_user(Username);
|
9 | return new Promise((resolve, reject) => {
|
10 | user.authenticateUser(AuthenticationDetails__, {
|
11 | onSuccess(session) {
|
12 | resolve({ session, user });
|
13 | },
|
14 | onFailure(err) {
|
15 | reject(err.message || JSON.stringify(err));
|
16 | },
|
17 | });
|
18 | });
|
19 | }
|