Browse Source
Merge pull request #16526 from abpframework/auto-merge/rel-7-0/1935
Merge branch rel-7.1 with rel-7.0
pull/16535/head
Mahmut Gundogdu
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
21 additions and
2 deletions
-
templates/app/react-native/src/api/AccountAPI.js
|
|
|
@ -3,15 +3,34 @@ import { getEnvVars } from '../../Environment'; |
|
|
|
|
|
|
|
const { oAuthConfig } = getEnvVars(); |
|
|
|
|
|
|
|
getLoginData = (username, password) => { |
|
|
|
|
|
|
|
const formData = { |
|
|
|
grant_type: 'password', |
|
|
|
scope: oAuthConfig.scope, |
|
|
|
username: username, |
|
|
|
password: password, |
|
|
|
client_id: oAuthConfig.clientId |
|
|
|
}; |
|
|
|
|
|
|
|
if (oAuthConfig.clientSecret) |
|
|
|
formData['client_secret'] = oAuthConfig.clientSecret; |
|
|
|
|
|
|
|
return Object.entries(formData) |
|
|
|
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`) |
|
|
|
.join('&'); |
|
|
|
} |
|
|
|
|
|
|
|
export const login = ({ username, password }) => |
|
|
|
api({ |
|
|
|
method: 'POST', |
|
|
|
url: '/connect/token', |
|
|
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, |
|
|
|
data: `grant_type=password&scope=${oAuthConfig.scope}&username=${username}&password=${password}&client_id=${oAuthConfig.clientId}&client_secret=${oAuthConfig.clientSecret}`, |
|
|
|
baseURL: oAuthConfig.issuer, |
|
|
|
data: getLoginData(username, password), |
|
|
|
baseURL: oAuthConfig.issuer |
|
|
|
}).then(({ data }) => data); |
|
|
|
|
|
|
|
|
|
|
|
export const Logout = () => |
|
|
|
api({ |
|
|
|
method: 'GET', |
|
|
|
|