Skip to content

Commit

Permalink
Merge pull request #65 from vietredweb/Issue-64
Browse files Browse the repository at this point in the history
fixes #64 Demo user
  • Loading branch information
lunguyenhat authored May 9, 2023
2 parents 90a0dff + 985d96f commit c0c5154
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/SSOButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { handleWalletResponse } from '../utils/index';
import Spinner from '../Spinner/index';

const SSOButton = ({ className, text, onGetData, options }) => {
const SSOButton = ({ className, text, onGetData, options, demoUser, demoPassword }) => {
const [loading, setLoading] = useState(false);

const handleSSO = async () => {
Expand All @@ -11,7 +11,9 @@ const SSOButton = ({ className, text, onGetData, options }) => {
process.env.REACT_APP_ENDPOINT_URL ?? process.env.NEXT_PUBLIC_ENDPOINT_URL,
process.env.REACT_APP_SSO_CLIENT_ID ?? process.env.NEXT_PUBLIC_SSO_CLIENT_ID,
onGetData,
options
options,
demoUser,
demoPassword
);
};

Expand Down
4 changes: 3 additions & 1 deletion src/sso.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const aesirxSSO = async () => {
window.aesirxEndpoint,
window.aesirxClientID,
onGetData,
window.aesirxAllowedLogins
window.aesirxAllowedLogins,
window.demoUser,
window.demoPassword
);
};
handleRegularReponse(
Expand Down
8 changes: 6 additions & 2 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ const handleWalletResponse = (
_endPoint,
clientID,
onGetData,
aesirxAllowedLogins = ['concordium', 'metamask', 'regular']
aesirxAllowedLogins = ['concordium', 'metamask', 'regular'],
demoUser,
demoPassword
) => {
const endPoint = _endPoint ? new URL(_endPoint)?.origin : '';
const optionList = aesirxAllowedLogins?.length
? aesirxAllowedLogins?.map((item) => `&login[]=${item}`).join('')
: '';
const ssoState = 'sso';
const popupLink = `${endPoint}/index.php?option=authorize&api=oauth2&response_type=code&client_id=${clientID}&state=${ssoState}${optionList}`;
const demoAccount =
demoUser && demoPassword ? '&demo_user=' + demoUser + '&demo_password=' + demoPassword : '';
const popupLink = `${endPoint}/index.php?option=authorize&api=oauth2&response_type=code&client_id=${clientID}&state=${ssoState}${optionList}${demoAccount}`;
let popup = window.open(popupLink, 'SSO', 'status=1,height=650,width=650');
var timer = setInterval(async () => {
if (popup.closed) {
Expand Down

0 comments on commit c0c5154

Please sign in to comment.