-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth): enable auth flow (with some redirects to bl-login)
- Loading branch information
1 parent
ef151b2
commit 156505d
Showing
24 changed files
with
346 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { UserDetail } from "@boklisten/bl-model"; | ||
|
||
import { add, patch } from "@/api/api"; | ||
import { parseTokensFromResponseDataAndStore } from "@/api/token"; | ||
import BL_CONFIG from "@/utils/bl-config"; | ||
import { verifyBlError } from "@/utils/types"; | ||
|
||
export const login = async (username: string, password: string) => { | ||
const apiResponse = await add(BL_CONFIG.login.local.url, { | ||
username, | ||
password, | ||
}); | ||
if (!verifyBlError(apiResponse)) { | ||
parseTokensFromResponseDataAndStore(apiResponse.data); | ||
} | ||
return apiResponse; | ||
}; | ||
|
||
export const registerUser = async (username: string, password: string) => { | ||
const apiResponse = await add(BL_CONFIG.register.local.url, { | ||
username, | ||
password, | ||
}); | ||
if (!verifyBlError(apiResponse)) { | ||
parseTokensFromResponseDataAndStore(apiResponse.data); | ||
} | ||
return apiResponse; | ||
}; | ||
|
||
export const updateUserDetails = async ( | ||
userId: string, | ||
userDetails: Partial<UserDetail>, | ||
) => { | ||
return await patch( | ||
`${BL_CONFIG.collection.userDetail}/${userId}`, | ||
userDetails, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use client"; | ||
import { redirect } from "next/navigation"; | ||
|
||
import { logout } from "@/api/auth"; | ||
import { attachTokensToHref } from "@/components/AuthLinker"; | ||
import BL_CONFIG from "@/utils/bl-config"; | ||
|
||
export default function LogoutPage() { | ||
logout(); | ||
redirect(attachTokensToHref(BL_CONFIG.blWeb.basePath + "auth/logout")); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
|
||
export default function TokenRedirectPage() { | ||
const router = useRouter(); | ||
useEffect(() => { | ||
// Redirect after tokens have been captured | ||
setTimeout(() => { | ||
router.push("/"); | ||
}, 100); | ||
}, [router]); | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use client"; | ||
import { redirect } from "next/navigation"; | ||
|
||
import { attachTokensToHref } from "@/components/AuthLinker"; | ||
import BL_CONFIG from "@/utils/bl-config"; | ||
|
||
export default function ItemsPage() { | ||
redirect(attachTokensToHref(BL_CONFIG.blWeb.basePath + "u/items")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use client"; | ||
import { redirect } from "next/navigation"; | ||
|
||
import { attachTokensToHref } from "@/components/AuthLinker"; | ||
import BL_CONFIG from "@/utils/bl-config"; | ||
|
||
export default function OrdersPage() { | ||
redirect(attachTokensToHref(BL_CONFIG.blWeb.basePath + "u/order")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use client"; | ||
import { redirect } from "next/navigation"; | ||
|
||
import { attachTokensToHref } from "@/components/AuthLinker"; | ||
import BL_CONFIG from "@/utils/bl-config"; | ||
|
||
export default function OrderPage() { | ||
redirect(attachTokensToHref(BL_CONFIG.blWeb.basePath + "fastbuy/regions")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
"use client"; | ||
import { redirect } from "next/navigation"; | ||
|
||
import { attachTokensToHref } from "@/components/AuthLinker"; | ||
import BL_CONFIG from "@/utils/bl-config"; | ||
|
||
export default function IndexPage() { | ||
redirect(BL_CONFIG.blWeb.basePath); | ||
redirect(attachTokensToHref(BL_CONFIG.blWeb.basePath)); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.