Skip to content

Commit

Permalink
Show info about auth provider #19
Browse files Browse the repository at this point in the history
  • Loading branch information
sroertgen committed Apr 22, 2024
1 parent 5da3308 commit 68c759a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion public/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@
<div class="form-group">
<label>
<% if(data?.user?.id){ %>
<p>Logged in ✅ (<a href="/logout">Logout</a>)</p>
<p>Logged in
<%if(data.user.authProvider === "wikimedia") {%>
<img src="img/wikimedia.svg" alt="wikimedia" style="height: 1em; vertical-align: middle;">
<% } else{ %>
<img src="img/orcid.svg" alt="orcid" style="height: 1em; vertical-align: middle;">
<% } %>
(<a href="/logout">Logout</a>)
</p>
<% } else{ %>
<span>Login with</span>
<a href="/auth/mediawiki">Wikimedia</a>
Expand Down
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ passport.use("wikimedia", new OAuth2Strategy({
fetch(url, options)
.then(response => response.json())
.then(({ query: { userinfo } }) => {
cb(null, { id: userinfo.id }
cb(null, {
id: userinfo.id,
authProvider: "wikimedia"
}
)
})
.catch(error => console.error('Error fetching user info:', error));
Expand Down Expand Up @@ -92,7 +95,10 @@ passport.use("orcid", new OAuth2Strategy({
fetch(url, options)
.then(response => response.json())
.then(data => {
cb(null, { id: data.sub }
cb(null, {
id: data.sub,
authProvider: "orcid"
}
)
})
.catch(error => console.error('Error fetching user info:', error));
Expand Down

0 comments on commit 68c759a

Please sign in to comment.