@ssplib/react-components 0.0.84 → 0.0.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export default function NavBar({ links, title, img, pos, next, el, menuItems, logoutMsg, logoutURL, }: {
2
+ export default function NavBar({ links, title, img, pos, next, el, menuItems, logoutMsg, }: {
3
3
  links: {
4
4
  name: string;
5
5
  path: string;
@@ -10,6 +10,5 @@ export default function NavBar({ links, title, img, pos, next, el, menuItems, lo
10
10
  next?: boolean;
11
11
  el?: JSX.Element;
12
12
  logoutMsg?: string;
13
- logoutURL?: string;
14
13
  pos?: 'fixed' | 'inherit';
15
14
  }): JSX.Element;
@@ -37,7 +37,7 @@ const link_1 = __importDefault(require("next/link"));
37
37
  const router_1 = require("next/router");
38
38
  const react_1 = __importStar(require("react"));
39
39
  const auth_1 = require("../../context/auth");
40
- function NavBar({ links, title, img, pos = 'fixed', next = true, el, menuItems, logoutMsg = 'Sair', logoutURL = '/', }) {
40
+ function NavBar({ links, title, img, pos = 'fixed', next = true, el, menuItems, logoutMsg = 'Sair', }) {
41
41
  let router = undefined;
42
42
  if (next)
43
43
  router = (0, router_1.useRouter)();
@@ -107,7 +107,7 @@ function NavBar({ links, title, img, pos = 'fixed', next = true, el, menuItems,
107
107
  menuItems,
108
108
  react_1.default.createElement(material_1.MenuItem, { onClick: (e) => {
109
109
  setAvatarAnchor(null);
110
- logout(logoutURL);
110
+ logout();
111
111
  } },
112
112
  react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 1 },
113
113
  react_1.default.createElement(LogoutOutlined_1.default, { sx: { fill: '#545454' } }),
@@ -13,7 +13,7 @@ interface OiDcConfig {
13
13
  CODE_VERIFIER: string;
14
14
  }
15
15
  export declare const cookieName = "nextauth.token";
16
- export declare function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTokenRoute, testToken, testIP, }: {
16
+ export declare function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTokenRoute, testToken, testIP, logoutURL, }: {
17
17
  children: JSX.Element | JSX.Element[];
18
18
  AUTH_URL: string;
19
19
  oidcConfig: OiDcConfig;
@@ -21,5 +21,6 @@ export declare function OAuthProvider({ children, AUTH_URL, oidcConfig, redirect
21
21
  validateTokenRoute: string;
22
22
  testToken: string;
23
23
  testIP?: string;
24
+ logoutURL?: string;
24
25
  }): JSX.Element;
25
26
  export {};
@@ -43,7 +43,7 @@ const react_1 = __importStar(require("react"));
43
43
  const auth_1 = require("../../context/auth");
44
44
  exports.cookieName = 'nextauth.token';
45
45
  const userImgName = 'user-data.img';
46
- function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTokenRoute, testToken, testIP, }) {
46
+ function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTokenRoute, testToken, testIP, logoutURL = redirectURL, }) {
47
47
  const govBrURL = oidcConfig.authority + '/authorize?response_type=code&client_id=' + oidcConfig.client_id + '&scope=' + oidcConfig.scope + '&redirect_uri=' + oidcConfig.redirect_uri;
48
48
  const [user, setUser] = (0, react_1.useState)();
49
49
  const [userLoaded, setUserLoaded] = (0, react_1.useState)(false);
@@ -62,7 +62,7 @@ function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTo
62
62
  },
63
63
  }).then((res) => {
64
64
  if (!res.ok) {
65
- logout('/');
65
+ logout();
66
66
  return;
67
67
  }
68
68
  else {
@@ -124,12 +124,12 @@ function OAuthProvider({ children, AUTH_URL, oidcConfig, redirectURL, validateTo
124
124
  router.replace(redirectURL).finally(() => setUserLoaded(true));
125
125
  });
126
126
  }
127
- function logout(url) {
127
+ function logout() {
128
128
  setUserLoaded(false);
129
129
  setUser(null);
130
130
  (0, cookies_next_1.deleteCookie)(exports.cookieName);
131
131
  localStorage.removeItem(userImgName);
132
- router.replace(url).finally(() => setUserLoaded(true));
132
+ router.replace(logoutURL).finally(() => setUserLoaded(true));
133
133
  }
134
134
  return react_1.default.createElement(auth_1.AuthContext.Provider, { value: { user, isAuth, userLoaded, login, adLogin: () => { }, logout, saveUserData, type: 'govbr' } }, children);
135
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.84",
3
+ "version": "0.0.85",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",
package/types/auth.d.ts CHANGED
@@ -69,5 +69,5 @@ export interface AuthReturnData {
69
69
  login: () => void;
70
70
  adLogin: (loginURL: string, data: any, setLoading: React.Dispatch<React.SetStateAction<boolean>>, setError: React.Dispatch<React.SetStateAction<boolean>>, captchaToken: string) => void;
71
71
  saveUserData: (token: AuthReturn) => void;
72
- logout: (url: string) => void;
72
+ logout: () => void;
73
73
  }