persistant storage for vuex, logging instead of console.log, profile support
This commit is contained in:
@@ -1,46 +1,51 @@
|
||||
import Vue from 'vue';
|
||||
import axios from 'axios';
|
||||
|
||||
const API_URL = 'http://localhost:5443/api';
|
||||
|
||||
export function fetchSurveys () {
|
||||
return axios.get(`${API_URL}/surveys/`)
|
||||
export function fetchSurveys() {
|
||||
return axios.get(`${API_URL}/surveys/`);
|
||||
}
|
||||
|
||||
export function fetchSurvey (surveyId: string) {
|
||||
return axios.get(`${API_URL}/surveys/${surveyId}/`)
|
||||
export function fetchSurvey(surveyId: string) {
|
||||
return axios.get(`${API_URL}/surveys/${surveyId}/`);
|
||||
}
|
||||
|
||||
export function saveSurveyResponse (surveyResponse: any) {
|
||||
return axios.put(`${API_URL}/surveys/${surveyResponse.id}/`, surveyResponse)
|
||||
export function saveSurveyResponse(surveyResponse: any) {
|
||||
return axios.put(`${API_URL}/surveys/${surveyResponse.id}/`, surveyResponse);
|
||||
}
|
||||
|
||||
export function postNewSurvey (survey: any, jwt: any) {
|
||||
return axios.post(`${API_URL}/surveys/`, survey, { headers: { Authorization: `Bearer ${jwt}` } })
|
||||
export function postNewSurvey(survey: any, jwt: any) {
|
||||
return axios.post(`${API_URL}/surveys/`, survey, { headers: { Authorization: `Bearer ${jwt}` } });
|
||||
}
|
||||
|
||||
export function authenticate (userData: any) {
|
||||
return axios.post(`${API_URL}/auth/login`, userData)
|
||||
export function authenticate(userData: any) {
|
||||
return axios.post(`${API_URL}/auth/login`, userData);
|
||||
}
|
||||
|
||||
export function register (userData: any) {
|
||||
return axios.post(`${API_URL}/auth/register`, userData)
|
||||
export function register(userData: any) {
|
||||
return axios.post(`${API_URL}/auth/register`, userData);
|
||||
}
|
||||
|
||||
// This function probably isn't really useful here, as a user must be redirected to the actual OIDC provider.
|
||||
// -> So login involves user interaction through the frontend (and not just API calls).
|
||||
export function oidc_login (redirection_url: any) {
|
||||
return axios.get(`${API_URL}/auth/oidc`, redirection_url)
|
||||
export function oidc_login(redirectionUrl: any) {
|
||||
return axios.get(`${API_URL}/auth/oidc`, redirectionUrl);
|
||||
}
|
||||
|
||||
export function getFreshToken (refresh_token: any) {
|
||||
return axios.get(`${API_URL}/auth/fresh`, refresh_token)
|
||||
export function getFreshToken(refreshToken: any) {
|
||||
return axios.get(`${API_URL}/auth/fresh`, refreshToken);
|
||||
}
|
||||
|
||||
export function getProviders () {
|
||||
return axios.get(`${API_URL}/auth/providers`)
|
||||
export function getProviders() {
|
||||
return axios.get(`${API_URL}/auth/providers`);
|
||||
}
|
||||
|
||||
export function fetchUsers (jwt: any) {
|
||||
console.log("JWT: " + jwt);
|
||||
return axios.get(`${API_URL}/v1/user`, { headers: { Authorization: `Bearer ${jwt}` } })
|
||||
export function fetchUsers(jwt: any) {
|
||||
return axios.get(`${API_URL}/v1/user`, { headers: { Authorization: `Bearer ${jwt}` } });
|
||||
}
|
||||
|
||||
export function fetchProfile(jwt: any) {
|
||||
Vue.$log.debug("JWT: "+ jwt);
|
||||
return axios.get(`${API_URL}/v1/user/profile`, { headers: { Authorization: `Bearer ${jwt}` } });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user