You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR implements some improvement to mark the second iteration of the
`auth` feature in the project. Follow-up to #8
### Changes Made
- Addressed "todo make the `parsedState` data more predictable (order by
path, redirect)" by implementing more predicatable manner of generating
the `state` string for the oauth url; this is done by individually
looking for the required `state` object `key` to fill in the
`parsedState` string in required order. Leaving the new `getAuthUrl`
helper function looking like so...
```js
function getAuthUrl(state) {
let parsedState = "";
if (!isObjectEmpty(state)){
if (state.path) parsedState += `path:${state.path}`;
const otherStates = String(Object.keys(state)
.filter(key => key !== "path" && key !== "redirect")
.map(key => key + ":" + state[key]).join("|"));
if (otherStates.length > 0) parsedState += `|${otherStates}`;
}
const { url } = app.oauth.getWebFlowAuthorizationUrl({
state: parsedState
});
return url;
}
```
- Implemented a new utility function `isObjectEmpty` to check if an
object has value or not
- Removed usage of `redirect` property in state object; its redundant
😮💨
- Renamed login redirect path params property name to `return_to` from
`redirect` for readability reasons
- Implemented `encodeURIComponent` in login redirect path params value
to stop its part on the url from looking like weird 😃;
- Takes the example url from looking like this...
`/login?return_to=/editor` to looking like so...
`/login?return_to=%2Feditor`
### Related Isssue
Resolves#15
0 commit comments