Skip to content

Commit 114cd0a

Browse files
authored
Merge pull request #350 from fractal-analytics-platform/align-1.4.0
Used new endpoints for retrieving current user and list of users
2 parents 2dfbaf0 + e9dff1b commit 114cd0a

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
This release requires fractal-server 1.4.0.
66

7+
* Used new endpoints for retrieving current user and list of users (\#350).
78
* Added user profile page (\#336).
89
* Added admin area with users management (\#336).
910
* Added Jobs button in home page (\#346).

playwright.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default defineConfig({
3838

3939
webServer: [
4040
{
41-
command: './tests/start-test-server.sh 1.4.0a6',
41+
command: './tests/start-test-server.sh 1.4.0a8',
4242
port: 8000,
4343
waitForPort: true,
4444
stdout: 'pipe',

src/hooks.server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export async function handle({ event, resolve }) {
2424
});
2525
}
2626

27-
const whoami = await event.fetch(`${FRACTAL_SERVER_HOST}/auth/whoami/`);
28-
if (!whoami.ok) {
27+
const currentUser = await event.fetch(`${FRACTAL_SERVER_HOST}/auth/current-user/`);
28+
if (!currentUser.ok) {
2929
console.log('Validation of authentication - Error loading user info');
3030
return new Response(null, {
3131
status: 302,
@@ -34,7 +34,7 @@ export async function handle({ event, resolve }) {
3434
}
3535

3636
if (event.url.pathname.startsWith('/admin')) {
37-
const user = await whoami.json();
37+
const user = await currentUser.json();
3838
if (!user.is_superuser) {
3939
throw error(403, `Only superusers can access the admin area`);
4040
}

src/lib/server/api/v1/auth_api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export async function userAuthentication(fetch, data) {
2727
* @param {typeof fetch} fetch
2828
* @returns {Promise<*>}
2929
*/
30-
export async function whoami(fetch) {
31-
const response = await fetch(FRACTAL_SERVER_HOST + '/auth/whoami/', {
30+
export async function getCurrentUser(fetch) {
31+
const response = await fetch(FRACTAL_SERVER_HOST + '/auth/current-user/', {
3232
method: 'GET',
3333
credentials: 'include',
3434
mode: 'cors'
@@ -68,7 +68,7 @@ export async function logout(fetch) {
6868
* @returns {Promise<*>}
6969
*/
7070
export async function listUsers(fetch) {
71-
const response = await fetch(FRACTAL_SERVER_HOST + '/auth/userlist/', {
71+
const response = await fetch(FRACTAL_SERVER_HOST + '/auth/users/', {
7272
method: 'GET',
7373
credentials: 'include'
7474
});

src/routes/+layout.server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FRACTAL_SERVER_HOST } from '$env/static/private';
2-
import { whoami } from '$lib/server/api/v1/auth_api';
2+
import { getCurrentUser } from '$lib/server/api/v1/auth_api';
33

44
export async function load({ fetch, cookies }) {
55
// This is a mark to notify and log when the server is running SSR
@@ -29,7 +29,7 @@ export async function load({ fetch, cookies }) {
2929
};
3030
}
3131

32-
const userInfo = await whoami(fetch).catch((error) => {
32+
const userInfo = await getCurrentUser(fetch).catch((error) => {
3333
console.log('Error loading user info');
3434
console.error(error);
3535
return null;

0 commit comments

Comments
 (0)