✨ 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 { createSignal, Show } from "solid-js";
|
||||
import { readWellKnown } from "../stores/wellKnown.tsx";
|
||||
import { BeforeLeaveEventArgs, useBeforeLeave, useNavigate } from "@solidjs/router";
|
||||
|
||||
export default function RootLayout(props: any) {
|
||||
const [ready, setReady] = createSignal(false);
|
||||
|
||||
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 (
|
||||
<Show when={ready()} fallback={
|
||||
<div class="h-screen w-screen flex justify-center items-center">
|
||||
|
@ -1,5 +1,5 @@
|
||||
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 Cookie from "universal-cookie";
|
||||
|
||||
@ -15,6 +15,8 @@ export default function LoginPage() {
|
||||
const [challenge, setChallenge] = createSignal<any>();
|
||||
const [stage, setStage] = createSignal("starting");
|
||||
|
||||
const[searchParams] = useSearchParams()
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handlers: { [id: string]: any } = {
|
||||
@ -87,7 +89,7 @@ export default function LoginPage() {
|
||||
if (data["is_finished"]) {
|
||||
await grantToken(data["session"]["grant_token"]);
|
||||
await readProfiles();
|
||||
navigate("/");
|
||||
navigate(searchParams["redirect_uri"] ?? "/");
|
||||
} else {
|
||||
setError(null);
|
||||
setStage("choosing");
|
||||
@ -211,7 +213,7 @@ export default function LoginPage() {
|
||||
</div>
|
||||
|
||||
<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>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { createSignal, Show } from "solid-js";
|
||||
import { useWellKnown } from "../../stores/wellKnown.tsx";
|
||||
import { useNavigate, useSearchParams } from "@solidjs/router";
|
||||
|
||||
export default function RegisterPage() {
|
||||
const [title, setTitle] = createSignal("Create an account");
|
||||
@ -9,7 +10,10 @@ export default function RegisterPage() {
|
||||
const [loading, setLoading] = createSignal(false);
|
||||
const [done, setDone] = createSignal(false);
|
||||
|
||||
const [searchParams] = useSearchParams()
|
||||
|
||||
const metadata = useWellKnown();
|
||||
const navigate = useNavigate();
|
||||
|
||||
async function submit(evt: SubmitEvent) {
|
||||
evt.preventDefault();
|
||||
@ -34,6 +38,14 @@ export default function RegisterPage() {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
function callback() {
|
||||
if(searchParams["closable"]) {
|
||||
window.close()
|
||||
} else {
|
||||
navigate("/auth/login")
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="w-full h-full flex justify-center items-center">
|
||||
<div>
|
||||
@ -124,7 +136,7 @@ export default function RegisterPage() {
|
||||
<div class="py-12 text-center">
|
||||
<h2 class="text-lg font-bold">What's next?</h2>
|
||||
<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.
|
||||
</span>
|
||||
</div>
|
||||
@ -133,7 +145,7 @@ export default function RegisterPage() {
|
||||
</div>
|
||||
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user