Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 7c8fd7e

Browse files
authored
Merge pull request #28 from cagdas001/milestone-19
feat: add businessLogin function
2 parents dad0995 + dc55663 commit 7c8fd7e

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Make sure you have [Heroky CLI](https://devcenter.heroku.com/articles/heroku-cli
6161
This app exports functions to be imported by other microapps.
6262

6363
- `login` - redirects to login page
64+
- `businessLogin` - redirects to business (i.e. customer) login page
6465
- `logout` - clears session storage and redirects to logout page
6566
- `setAppMenu` - sets sidebar menu for the app by app's `path`
6667
- `getAuthUserTokens` - returns a promise which resolves to object with user tokens `{ tokenV3, tokenV2 }`
@@ -95,6 +96,7 @@ For example see https://github.com/topcoder-platform/micro-frontends-react-app
9596
```js
9697
module.exports = {
9798
login: () => {},
99+
businessLogin: () => {},
98100
logout: () => {},
99101
setAppMenu: () => {},
100102
getAuthUserTokens: () => new Promise(() => {}),
@@ -121,6 +123,7 @@ For example see https://github.com/topcoder-platform/micro-frontends-angular-app
121123
```js
122124
declare module '@topcoder/micro-frontends-navbar-app' {
123125
export const login: any;
126+
export const businessLogin: any;
124127
export const logout: any;
125128
export const setAppMenu: any;
126129
export const getAuthUserTokens: any;

src/topcoder-micro-frontends-navbar-app.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
setNotificationPlatform,
2020
} from "./utils/exports";
2121

22-
import { login, logout } from "./utils";
22+
import { login, businessLogin, logout } from "./utils";
2323
import { PLATFORM } from "./constants/notifications";
2424

2525
const lifecycles = singleSpaReact({
@@ -37,6 +37,7 @@ export const { bootstrap, mount, unmount } = lifecycles;
3737
// list everything we want to export for other microapps here
3838
export {
3939
login,
40+
businessLogin,
4041
logout,
4142
setAppMenu,
4243
getAuthUserTokens,

src/utils/index.js

+17
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ export const getLoginUrl = () =>
1616
window.location.href.match(/[^?]*/)[0]
1717
)}`;
1818

19+
/**
20+
* Generate Business Login URL
21+
*/
22+
export const getBusinessLoginUrl = () =>
23+
`${
24+
config.URL.AUTH
25+
}?regSource=tcBusiness&mode=login&retUrl=${encodeURIComponent(
26+
window.location.href.match(/[^?]*/)[0]
27+
)}`;
28+
1929
/**
2030
* Logout user from Topcoder
2131
*/
@@ -30,3 +40,10 @@ export const logout = () => {
3040
export const login = () => {
3141
window.location = getLoginUrl();
3242
};
43+
44+
/**
45+
* Forward user to business login page
46+
*/
47+
export const businessLogin = () => {
48+
window.location = getBusinessLoginUrl();
49+
};

0 commit comments

Comments
 (0)