Skip to content

Commit

Permalink
Updated solid login and logout flow with SessionProvider. Now tracks
Browse files Browse the repository at this point in the history
when the user is logged in a more consistent way. Lacks session
persistance when the page is refreshed.

The shipping costs do not work.
  • Loading branch information
jbritosm committed Apr 2, 2022
1 parent 04fbe29 commit b2ac719
Show file tree
Hide file tree
Showing 16 changed files with 1,147 additions and 92 deletions.
3 changes: 3 additions & 0 deletions restapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ ENV RESTAPI_DB_PASSWORD=$DB_PASSWORD
ARG PORT="5000"
ENV RESTAPI_PORT=$PORT

ARG URI
ENV WEBAPP_URI=$URI

CMD [ "npm", "start" ]
12 changes: 6 additions & 6 deletions restapi/solid/solidFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {getSessionFromStorage, Session} from "@inrupt/solid-client-authn-node";
import IContactData from "../interfaces/ContactDataInterface";

// Parametros para el logeo
const redirectUrl: string = process.env.REACT_API_URI + "/solid/redirect-from-solid-idp" // Esto se cambiara por otra pagina como por ejemplo /home.
const redirectUrl: string = process.env.WEBAPP_URI + "/solid/redirect-from-solid-idp"
const oidcIssuer: string = "https://solidcommunity.net/" // Name of the pod provider.
const clientName: string = "DeDe" // Name of the app.
const errorRedirect: string = "http://localhost:3000"
const errorRedirect: string = process.env.WEBAPP_URI + ""

export let solidLogin = async (req: Request, res: Response) => {
let session = new Session()
Expand All @@ -37,9 +37,9 @@ export let solidLogin = async (req: Request, res: Response) => {
export let redirectFromSolidIdp = async (req: Request, res: Response) => {
const session = await getSessionFromStorage(req.session.id);
if(session){
await session.handleIncomingRedirect(process.env.REACT_API_URI + "/solid${req.url}");
await session.handleIncomingRedirect(process.env.WEBAPP_URI + "/solid" + req.url);
if(session.info.isLoggedIn)
return res.redirect("http://localhost:3000/solid/login/"+ Buffer.from(`${session.info.webId}`).toString("base64") + "/" + session.info.sessionId)
return res.redirect(process.env.WEBAPP_URI + "/solid/login/"+ Buffer.from(`${session.info.webId}`).toString("base64") + "/" + session.info.sessionId)

} else {
res.redirect(errorRedirect)
Expand All @@ -58,10 +58,10 @@ export let solidLogout = async (req: Request, res: Response) => {
if(session) {
session.logout()
.then(() => {
res.redirect("http://localhost:3000/solid/logout")
res.redirect(process.env.WEBAPP_URI + "/solid/logout")
})
} else {
res.redirect("http://localhost:3000/solid/logout")
res.redirect(process.env.WEBAPP_URI + "/solid/logout")
}
}

Expand Down
Loading

0 comments on commit b2ac719

Please sign in to comment.