Skip to content

Commit

Permalink
Merge branch 'staging' into fix-panel-handel
Browse files Browse the repository at this point in the history
  • Loading branch information
Anchel123 authored Sep 22, 2024
2 parents c083d25 + bf47cad commit d7e657a
Show file tree
Hide file tree
Showing 5 changed files with 1,204 additions and 377 deletions.
22 changes: 11 additions & 11 deletions app/api/auth/[...nextauth]/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function newClient(credentials: { host: string, port: string, password: st
const connectionOptions: FalkorDBOptions = credentials.ca === "undefined" ?
{
socket: {
host: credentials.host ?? "localhost",
host: credentials.host || "localhost",
port: credentials.port ? parseInt(credentials.port, 10) : 6379,
},
password: credentials.password ?? undefined,
Expand Down Expand Up @@ -51,25 +51,25 @@ async function newClient(credentials: { host: string, port: string, password: st
const connection = await client.connection

try {
connection.aclGetUser(credentials.username || "default")
await connection.aclGetUser(credentials.username || "default")
return { role: "Admin", client }
} catch (error: unknown) {
if (error instanceof ErrorReply && (error as ErrorReply).message.startsWith("NOPERM")) {
console.debug(error);
} else throw error
} catch (err) {
if (err instanceof ErrorReply && (err as ErrorReply).message.startsWith("NOPERM")) {
console.debug(err);
} else throw err
}

try {
await connection.sendCommand(["GRAPH.QUERY"])
} catch (error: unknown) {
if ((error as Error).message.includes("permissions")) {
console.debug(error);
} catch (err) {
if ((err as Error).message.includes("permissions")) {
console.debug(err);
return { role: "Read-Only", client }
}
console.debug(error);
console.debug(err);
return { role: "Read-Write", client }
}

return { role: "Admin", client }
}

Expand Down
4 changes: 2 additions & 2 deletions app/api/user/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface CreateUser {
export const ROLE = new Map<string, string[]>(
[
["Admin", ["on", "~*", "&*", "+@all"]],
["Read-Write", ["on", "~*", "resetchannels", "-@all", "+graph.query", "+graph.explain", "+graph.list", "+ping", "+graph.profile",]],
["Read-Only", ["on", "~*", "resetchannels", "-@all", "+graph.ro_query", "+graph.explain", "+graph.list", "+ping"]]
["Read-Write", ["on", "~*", "resetchannels", "-@all", "+graph.query", "+graph.ro_query", "+graph.explain", "+graph.list", "+ping", "+graph.profile", "+info"]],
["Read-Only", ["on", "~*", "resetchannels", "-@all", "+graph.ro_query", "+graph.explain", "+graph.list", "+ping", "+info"]]
]
)
5 changes: 3 additions & 2 deletions app/login/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default function LoginForm() {

const params: SignInOptions = {
redirect: false,
host: host.trim() ?? DEFAULT_HOST,
port: port.trim() ?? DEFAULT_PORT,
host: host.trim(),
port: port.trim(),
tls: TLS,
ca: CA
};
Expand All @@ -55,6 +55,7 @@ export default function LoginForm() {
if (password) {
params.password = password;
}

signIn("credentials", params).then((res?: SignInResponse) => {
if (res?.error) {
setError(true);
Expand Down
Loading

0 comments on commit d7e657a

Please sign in to comment.