feat: create a guild (#1)

This commit is contained in:
Divlo
2021-10-26 16:38:55 +02:00
committed by GitHub
parent a0fa66e8f5
commit d8fab08585
45 changed files with 530 additions and 315 deletions

View File

@ -1,8 +1,8 @@
import axios, { AxiosInstance } from 'axios'
import { io, Socket } from 'socket.io-client'
import { API_URL } from 'utils/api'
import { cookies } from 'utils/cookies'
import { API_URL } from '../api'
import { cookies } from '../cookies'
import { Tokens } from './'
import { fetchRefreshToken } from './authenticationFromServerSide'
@ -46,6 +46,7 @@ export class Authentication {
)
this.setAccessToken(accessToken)
}
config.headers = config.headers == null ? {} : config.headers
config.headers.Authorization = `${this.tokens.type} ${this.tokens.accessToken}`
return config
},

View File

@ -1,10 +1,10 @@
import { createContext, useState, useEffect, useMemo, useContext } from 'react'
import { useTheme } from 'next-themes'
import useTranslation from 'next-translate/useTranslation'
import setLanguage from 'next-translate/setLanguage'
import { Authentication, PagePropsWithAuthentication } from './'
import { useTheme } from 'next-themes'
import { UserCurrent } from 'models/User'
import { UserCurrent } from '../../models/User'
export interface AuthenticationValue {
authentication: Authentication

View File

@ -1,10 +1,11 @@
import { AxiosInstance } from 'axios'
import { AxiosInstance, AxiosResponse } from 'axios'
import { GetServerSideProps, GetServerSidePropsContext, Redirect } from 'next'
import { api } from 'utils/api'
import { Cookies } from 'utils/cookies'
import { api } from '../api'
import { Cookies } from '../cookies'
import { RefreshTokenResponse, Tokens } from './index'
import { Authentication } from './Authentication'
import { UserCurrent } from '../../models/User'
export const fetchRefreshToken = async (
refreshToken: string
@ -70,9 +71,10 @@ export const authenticationFromServerSide = (
} else {
let data: Redirect | any = {}
const authentication = new Authentication(tokens)
const { data: currentUser } = await authentication.api.get(
'/users/current'
)
const { data: currentUser } = await authentication.api.get<
unknown,
AxiosResponse<UserCurrent>
>('/users/current')
if (fetchData != null) {
data = await fetchData(context, authentication.api)
}

View File

@ -1,4 +1,4 @@
import { UserCurrent } from 'models/User'
import { UserCurrent } from '../../models/User'
export interface RefreshTokenResponse {
accessToken: string