Skip to content

Commit

Permalink
auth changes for apps
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-nettica committed Dec 27, 2024
1 parent dd3d255 commit afb8400
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@
mounted() {
if (this.$route && this.$route.query && this.$route.query.redirect_uri) {
TokenService.saveRedirect(this.$route.query.redirect_uri)
TokenService.destroyToken() // force a token exchange
}
if (this.$route && this.$route.query && this.$route.query.code && this.$route.query.state) {
let redirect = TokenService.getRedirect()
if (redirect != null && redirect != "") {
TokenService.destroyRedirect()
var url = redirect + "?code=" + this.$route.query.code + "&state=" + this.$route.query.state + "&client_id=" + TokenService.getClientId();
window.location.replace(url);
return;
}
}
if (this.$route && this.$route.query && this.$route.query.referer) {
let r = TokenService.getReferer()
if (r == null) {
Expand Down
15 changes: 15 additions & 0 deletions ui/src/services/token.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ const WILD_SERVER_KEY = "wild_server";
const REFERER_KEY = "referer";
const STATE_KEY = "state";
const CODE_KEY = "code";
const REDIRECT_KEY = "redirect_uri";

export const getRedirect = () => {
return window.localStorage.getItem(REDIRECT_KEY);
};

export const saveRedirect = redirect => {
window.localStorage.setItem(REDIRECT_KEY, redirect);
};

export const destroyRedirect = () => {
window.localStorage.removeItem(REDIRECT_KEY);
};

export const getReferer = () => {
return window.localStorage.getItem(REFERER_KEY);
Expand Down Expand Up @@ -106,6 +118,9 @@ export const destroyClientId = () => {
};

export default {
getRedirect,
saveRedirect,
destroyRedirect,
getToken,
saveToken,
destroyToken,
Expand Down

0 comments on commit afb8400

Please sign in to comment.