Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MARKENG-2777] Added login check to view profile link when signed in #82

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "post-zen",
"author": "Brandon Castillo, Marketing Engineering, Postman.",
"version": "1.8.0",
"version": "1.9.0",
"api_version": 2,
"default_locale": "en-us",
"settings": [
Expand Down
25 changes: 25 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,31 @@
});
}

function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

(function addProfileLink() {
setTimeout(() => {
let profile = document.getElementById("pm-signed-in");
const isSignedIn = getCookie("ajs_user_id");
isSignedIn ? profile.setAttribute("href", `/hc/en-us/profiles/${isSignedIn}`) : profile.setAttribute("href", `/hc/en-us/profiles/shared`)
Dismissed Show dismissed Hide dismissed
}, 500)

}())


jQuery(document).ready(function () {
/* pmtSDK
Expand Down
2 changes: 1 addition & 1 deletion templates/header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
{{/unless}}
{{#if signed_in}}
<li class="nav-item">
<a class="nav-link uber-nav" href="/hc/en-us/profiles/preview"
<a id="pm-signed-in" class="nav-link uber-nav" href="/hc/en-us/profiles/preview"
onClick="ga('send', 'event', 'global-navbar', 'Click', 'profile');">
Profile
</a>
Expand Down
Loading