Skip to content

Related actions (signup/logout)

Signup

Description
Function used to register users to the application.

Definition
Function body defined in db/src/api/signup.sql view in github

Usage example

curl -X POST --cookie-jar cookies.txt \
-d '{"name":"Alice", "email":"alice@email.com","password":"pass"}' \
http://localhost:8080/auth/signup
const endpoint = 'http://localhost:8080';
await fetch(endpoint+'/auth/signup', {
    method: 'POST',
    body: JSON.stringify({name:'Alice', email:'alice@email.com',password:'pass'})
});
import axios from 'axios';
const client = axios.create({
    baseURL: 'http://localhost:8080'
    withCredentials: true
});
await client.post('/auth/signup', {name:'Alice', email:'alice@email.com',password:'pass'});
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const client = new ApolloClient({
    uri: 'http://localhost:8080/graphql/simple',
    cache: new InMemoryCache()
});
await client.query({ 
    query: gql` 
        mutation {
            signup(name: "Alice", email: "alice@email.com", password: "pass"){
                id 
            } 
        }
    `
});

Logout

Description
Logs out the user by deleting the SESSIONID cookie

Definition
Function body defined in db/src/api/logout.sql view in github

Usage example

curl -X POST --cookie-jar cookies.txt \
-d '{}' \
http://localhost:8080/auth/logout
const endpoint = 'http://localhost:8080';
await fetch(endpoint+'/auth/logout', {
    method: 'POST',
    body: '{}'
});
import axios from 'axios';
const client = axios.create({
    baseURL: 'http://localhost:8080'
    withCredentials: true
});
await client.post('/auth/logout');
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const client = new ApolloClient({
    uri: 'http://localhost:8080/graphql/simple',
    cache: new InMemoryCache()
});
await client.query({ 
    query: gql` 
        mutation {
            logout
        }
    `
});

Refresh token

Description
Sets a new SESSIONID cookie (provided the current one is still valid) in order to extend the session validity. This function is periodically called by subzero proxy code to automatically extend the session lifetime as long as the user is making calls to the API.

Definition
Function body defined in db/src/api/refresh_token.sql view in github

Usage example

curl -X GET --cookie-jar cookies.txt \
http://localhost:8080/auth/refresh_token
const endpoint = 'http://localhost:8080';
await fetch(endpoint+'/auth/refresh_token');
import axios from 'axios';
const client = axios.create({
    baseURL: 'http://localhost:8080'
    withCredentials: true
});
await client.get('/auth/refresh_token');
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const client = new ApolloClient({
    uri: 'http://localhost:8080/graphql/simple',
    cache: new InMemoryCache()
});
await client.query({ 
    query: gql` 
        query {
            refresh_token
        }
    `
});