Skip to content

Commit

Permalink
feat: v3 auth rework - fix #146
Browse files Browse the repository at this point in the history
  • Loading branch information
pagoru committed Nov 25, 2024
1 parent 565337c commit 64f3dad
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 82 deletions.
3 changes: 1 addition & 2 deletions app/client/src/modules/connection/components/ping/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

export * from './ping.component'
export * from "./ping.component";
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@

.hotels {
.list {
display: flex;
flex-direction: column;
gap: 0.5rem;

.list {
display: flex;
flex-direction: column;
gap: .5rem;

.item {
display: flex;
gap: 1rem;
background-color: var(--bg);
padding: 1rem 2rem;
}
.item {
display: flex;
gap: 1rem;
background-color: var(--bg);
padding: 1rem 2rem;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@

.tokens {
.list {
display: flex;
flex-direction: column;
gap: 0.5rem;

.list {
display: flex;
flex-direction: column;
gap: .5rem;

.item {
display: flex;
gap: 1rem;
background-color: var(--bg);
padding: 1rem 2rem;
}
.item {
display: flex;
gap: 1rem;
background-color: var(--bg);
padding: 1rem 2rem;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

export * from './users.component'
export * from "./users.component";
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@

.users {
.list {
display: flex;
flex-direction: column;
gap: 0.5rem;

.list {
display: flex;
flex-direction: column;
gap: .5rem;

.item {
display: flex;
gap: 1rem;
background-color: var(--bg);
padding: 1rem 2rem;
}
.item {
display: flex;
gap: 1rem;
background-color: var(--bg);
padding: 1rem 2rem;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.list {
display: flex;
flex-direction: column;
Expand Down
25 changes: 12 additions & 13 deletions app/client/src/modules/home/components/license/license.module.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

.container {
display: flex;
flex-direction: column;
gap: .5rem;
display: flex;
flex-direction: column;
gap: 0.5rem;

.license {
border-radius: .5rem;
padding: .5rem 1rem;
background-color: var(--inv-bg);
color: var(--bg-main);
font-weight: bold;
text-align: center;
}
}
.license {
border-radius: 0.5rem;
padding: 0.5rem 1rem;
background-color: var(--inv-bg);
color: var(--bg-main);
font-weight: bold;
text-align: center;
}
}
3 changes: 1 addition & 2 deletions app/client/src/modules/home/components/otp/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

export * from './otp.component'
export * from "./otp.component";
15 changes: 7 additions & 8 deletions app/client/src/modules/home/components/otp/otp.module.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

.form {
display: flex;
flex-direction: column;
gap: 1rem;
display: flex;
flex-direction: column;
gap: 1rem;

.qr {
max-width: 20rem;
}
}
.qr {
max-width: 20rem;
}
}
2 changes: 1 addition & 1 deletion app/client/src/modules/login/login.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const LoginComponent: React.FC = () => {
setErrorMessage(message);
});
},
[captchaId, navigate, setSubmittedAt, setErrorMessage]
[captchaId, navigate, setSubmittedAt, setErrorMessage],
);

if (isLogged === null) return <div>Loading...</div>;
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/modules/register/register.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const RegisterComponent: React.FC = () => {
setSubmittedAt(performance.now());
});
},
[captchaId, navigate]
[captchaId, navigate],
);

if (isLogged) return <RedirectComponent to="/" />;
Expand Down
6 changes: 6 additions & 0 deletions app/client/src/shared/hooks/useAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ export const useAccount = () => {
Cookies.set("account-id", accountId, {
expires: refreshTokenDuration,
sameSite: "strict",
secure: true,
});
Cookies.set("refresh-token", refreshToken, {
expires: refreshTokenDuration,
sameSite: "strict",
secure: true,
});
Cookies.set("token", token, {
expires: tokenDuration,
sameSite: "strict",
secure: true,
});
},
[fetch],
Expand Down Expand Up @@ -99,14 +102,17 @@ export const useAccount = () => {
Cookies.set("account-id", accountId, {
expires: refreshTokenDuration,
sameSite: "strict",
secure: true,
});
Cookies.set("refresh-token", refreshToken, {
expires: refreshTokenDuration,
sameSite: "strict",
secure: true,
});
Cookies.set("token", token, {
expires: tokenDuration,
sameSite: "strict",
secure: true,
});
}, [fetch]);

Expand Down
4 changes: 2 additions & 2 deletions app/client/src/shared/hooks/useAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const AdminProvider: React.FunctionComponent<ProviderProps> = ({
]);
return token;
},
[fetch, getAccountHeaders, setTokens]
[fetch, getAccountHeaders, setTokens],
);

const removeToken = useCallback(
Expand All @@ -86,7 +86,7 @@ export const AdminProvider: React.FunctionComponent<ProviderProps> = ({
});
setTokens((tokens) => tokens.filter((token) => token.id !== id));
},
[fetch, getAccountHeaders, setTokens]
[fetch, getAccountHeaders, setTokens],
);

const fetchHotels = useCallback(async () => {
Expand Down
6 changes: 6 additions & 0 deletions app/client/src/shared/hooks1/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ export const useApi = () => {
Cookies.set("sessionId", data.sessionId, {
expires: 7,
sameSite: "strict",
secure: true,
});
Cookies.set("refreshToken", data.refreshToken, {
expires: 7,
sameSite: "strict",
secure: true,
});
if (data.redirectUrl) setFallbackRedirectUrl(data.redirectUrl);
else
Cookies.set("token", data.token, {
expires: 1,
sameSite: "strict",
secure: true,
});
resolve(data);
})
Expand Down Expand Up @@ -87,16 +90,19 @@ export const useApi = () => {
Cookies.set("sessionId", sessionId, {
expires: 7,
sameSite: "strict",
secure: true,
});
Cookies.set("refreshToken", data.refreshToken, {
expires: 7,
sameSite: "strict",
secure: true,
});
if (data.redirectUrl) setFallbackRedirectUrl(data.redirectUrl);
else
Cookies.set("token", data.token, {
expires: 1,
sameSite: "strict",
secure: true,
});
return resolve(data);
}
Expand Down
6 changes: 3 additions & 3 deletions app/server/src/modules/api/v3/account/misc/bsky.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const bskyPostRequest: RequestType = {
{
status: 403,
},
{ status: 403 }
{ status: 403 },
);

const { did } = await request.json();
Expand All @@ -24,7 +24,7 @@ export const bskyPostRequest: RequestType = {
{ status: 403 },
{
status: 403,
}
},
);
const account = await System.accounts.getFromRequest(request);

Expand All @@ -39,7 +39,7 @@ export const bskyPostRequest: RequestType = {
},
{
status: 200,
}
},
);
},
};
16 changes: 8 additions & 8 deletions app/server/src/modules/api/v3/admin/main.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const adminPostRequest: RequestType = {
{
status: 403,
},
{ status: 403 }
{ status: 403 },
);

const adminList = await System.admins.getList();
Expand All @@ -27,7 +27,7 @@ export const adminPostRequest: RequestType = {
{
status: 200,
},
{ status: 200 }
{ status: 200 },
);
}

Expand All @@ -36,7 +36,7 @@ export const adminPostRequest: RequestType = {
{
status: 403,
},
{ status: 403 }
{ status: 403 },
);

const accountId = url.searchParams.get("accountId");
Expand All @@ -49,7 +49,7 @@ export const adminPostRequest: RequestType = {
{
status: 400,
},
{ status: 400 }
{ status: 400 },
);

await System.admins.set(accountId);
Expand All @@ -58,7 +58,7 @@ export const adminPostRequest: RequestType = {
{
status: 200,
},
{ status: 200 }
{ status: 200 },
);
},
};
Expand All @@ -73,7 +73,7 @@ export const adminDeleteRequest: RequestType = {
{
status: 403,
},
{ status: 403 }
{ status: 403 },
);

const accountId = url.searchParams.get("accountId");
Expand All @@ -82,7 +82,7 @@ export const adminDeleteRequest: RequestType = {
{
status: 400,
},
{ status: 400 }
{ status: 400 },
);

await System.admins.remove(accountId);
Expand All @@ -91,7 +91,7 @@ export const adminDeleteRequest: RequestType = {
{
status: 200,
},
{ status: 200 }
{ status: 200 },
);
},
};

0 comments on commit 64f3dad

Please sign in to comment.