✨ Redirect uri
This commit is contained in:
parent
3c58cb8f0a
commit
2c3d4f86c8
4
pkg/models/clients.go
Normal file
4
pkg/models/clients.go
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
type OauthClients struct {
|
||||||
|
}
|
@ -2,12 +2,24 @@ import Navbar from "./shared/Navbar.tsx";
|
|||||||
import { readProfiles } from "../stores/userinfo.tsx";
|
import { readProfiles } from "../stores/userinfo.tsx";
|
||||||
import { createSignal, Show } from "solid-js";
|
import { createSignal, Show } from "solid-js";
|
||||||
import { readWellKnown } from "../stores/wellKnown.tsx";
|
import { readWellKnown } from "../stores/wellKnown.tsx";
|
||||||
|
import { BeforeLeaveEventArgs, useBeforeLeave, useNavigate } from "@solidjs/router";
|
||||||
|
|
||||||
export default function RootLayout(props: any) {
|
export default function RootLayout(props: any) {
|
||||||
const [ready, setReady] = createSignal(false);
|
const [ready, setReady] = createSignal(false);
|
||||||
|
|
||||||
Promise.all([readWellKnown(), readProfiles()]).then(() => setReady(true));
|
Promise.all([readWellKnown(), readProfiles()]).then(() => setReady(true));
|
||||||
|
|
||||||
|
const navigate = useNavigate()
|
||||||
|
|
||||||
|
useBeforeLeave((e: BeforeLeaveEventArgs) => {
|
||||||
|
const whitelist = ["/auth/login", "/auth/register", "/users/me/confirm"]
|
||||||
|
|
||||||
|
if (!whitelist.includes(e.to.toString()) && !e.defaultPrevented) {
|
||||||
|
e.preventDefault();
|
||||||
|
navigate(`/auth/login?redirect_uri=${e.to.toString()}`)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Show when={ready()} fallback={
|
<Show when={ready()} fallback={
|
||||||
<div class="h-screen w-screen flex justify-center items-center">
|
<div class="h-screen w-screen flex justify-center items-center">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { readProfiles } from "../../stores/userinfo.tsx";
|
import { readProfiles } from "../../stores/userinfo.tsx";
|
||||||
import { useNavigate } from "@solidjs/router";
|
import { useNavigate, useSearchParams } from "@solidjs/router";
|
||||||
import { createSignal, For, Match, Show, Switch } from "solid-js";
|
import { createSignal, For, Match, Show, Switch } from "solid-js";
|
||||||
import Cookie from "universal-cookie";
|
import Cookie from "universal-cookie";
|
||||||
|
|
||||||
@ -15,6 +15,8 @@ export default function LoginPage() {
|
|||||||
const [challenge, setChallenge] = createSignal<any>();
|
const [challenge, setChallenge] = createSignal<any>();
|
||||||
const [stage, setStage] = createSignal("starting");
|
const [stage, setStage] = createSignal("starting");
|
||||||
|
|
||||||
|
const[searchParams] = useSearchParams()
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handlers: { [id: string]: any } = {
|
const handlers: { [id: string]: any } = {
|
||||||
@ -87,7 +89,7 @@ export default function LoginPage() {
|
|||||||
if (data["is_finished"]) {
|
if (data["is_finished"]) {
|
||||||
await grantToken(data["session"]["grant_token"]);
|
await grantToken(data["session"]["grant_token"]);
|
||||||
await readProfiles();
|
await readProfiles();
|
||||||
navigate("/");
|
navigate(searchParams["redirect_uri"] ?? "/");
|
||||||
} else {
|
} else {
|
||||||
setError(null);
|
setError(null);
|
||||||
setStage("choosing");
|
setStage("choosing");
|
||||||
@ -211,7 +213,7 @@ export default function LoginPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-sm text-center mt-3">
|
<div class="text-sm text-center mt-3">
|
||||||
<a href="/auth/register" class="link">Haven't an account? Click here to create one!</a>
|
<a target="_blank" href="/auth/register?closable=yes" class="link">Haven't an account? Click here to create one!</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { createSignal, Show } from "solid-js";
|
import { createSignal, Show } from "solid-js";
|
||||||
import { useWellKnown } from "../../stores/wellKnown.tsx";
|
import { useWellKnown } from "../../stores/wellKnown.tsx";
|
||||||
|
import { useNavigate, useSearchParams } from "@solidjs/router";
|
||||||
|
|
||||||
export default function RegisterPage() {
|
export default function RegisterPage() {
|
||||||
const [title, setTitle] = createSignal("Create an account");
|
const [title, setTitle] = createSignal("Create an account");
|
||||||
@ -9,7 +10,10 @@ export default function RegisterPage() {
|
|||||||
const [loading, setLoading] = createSignal(false);
|
const [loading, setLoading] = createSignal(false);
|
||||||
const [done, setDone] = createSignal(false);
|
const [done, setDone] = createSignal(false);
|
||||||
|
|
||||||
|
const [searchParams] = useSearchParams()
|
||||||
|
|
||||||
const metadata = useWellKnown();
|
const metadata = useWellKnown();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
async function submit(evt: SubmitEvent) {
|
async function submit(evt: SubmitEvent) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
@ -34,6 +38,14 @@ export default function RegisterPage() {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function callback() {
|
||||||
|
if(searchParams["closable"]) {
|
||||||
|
window.close()
|
||||||
|
} else {
|
||||||
|
navigate("/auth/login")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="w-full h-full flex justify-center items-center">
|
<div class="w-full h-full flex justify-center items-center">
|
||||||
<div>
|
<div>
|
||||||
@ -124,7 +136,7 @@ export default function RegisterPage() {
|
|||||||
<div class="py-12 text-center">
|
<div class="py-12 text-center">
|
||||||
<h2 class="text-lg font-bold">What's next?</h2>
|
<h2 class="text-lg font-bold">What's next?</h2>
|
||||||
<span>
|
<span>
|
||||||
<a href="/auth/login" class="link">Go login</a>{" "}
|
<a onClick={() => callback()} class="link">Go login</a>{" "}
|
||||||
then you can take part in the entire smartsheep community.
|
then you can take part in the entire smartsheep community.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -133,7 +145,7 @@ export default function RegisterPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-sm text-center mt-3">
|
<div class="text-sm text-center mt-3">
|
||||||
<a href="/auth/login" class="link">Already had an account? Login now!</a>
|
<a onClick={() => callback()} class="link">Already had an account? Login now!</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user