feat: Support dark mode in login pages (#7420)
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
6
app/javascript/v3/api/apiClient.js
Normal file
6
app/javascript/v3/api/apiClient.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const { apiHost = '' } = window.chatwootConfig || {};
|
||||
const wootAPI = axios.create({ baseURL: `${apiHost}/` });
|
||||
|
||||
export default wootAPI;
|
||||
74
app/javascript/v3/api/auth.js
Normal file
74
app/javascript/v3/api/auth.js
Normal file
@@ -0,0 +1,74 @@
|
||||
import {
|
||||
setAuthCredentials,
|
||||
throwErrorMessage,
|
||||
clearLocalStorageOnLogout,
|
||||
} from 'dashboard/store/utils/api';
|
||||
import wootAPI from './apiClient';
|
||||
import { getLoginRedirectURL } from '../helpers/AuthHelper';
|
||||
|
||||
export const login = async ({
|
||||
ssoAccountId,
|
||||
ssoConversationId,
|
||||
...credentials
|
||||
}) => {
|
||||
try {
|
||||
const response = await wootAPI.post('auth/sign_in', credentials);
|
||||
setAuthCredentials(response);
|
||||
clearLocalStorageOnLogout();
|
||||
window.location = getLoginRedirectURL({
|
||||
ssoAccountId,
|
||||
ssoConversationId,
|
||||
user: response.data.data,
|
||||
});
|
||||
} catch (error) {
|
||||
throwErrorMessage(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const register = async creds => {
|
||||
try {
|
||||
const response = await wootAPI.post('api/v1/accounts.json', {
|
||||
account_name: creds.accountName.trim(),
|
||||
user_full_name: creds.fullName.trim(),
|
||||
email: creds.email,
|
||||
password: creds.password,
|
||||
h_captcha_client_response: creds.hCaptchaClientResponse,
|
||||
});
|
||||
setAuthCredentials(response);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throwErrorMessage(error);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export const verifyPasswordToken = async ({ confirmationToken }) => {
|
||||
try {
|
||||
const response = await wootAPI.post('auth/confirmation', {
|
||||
confirmation_token: confirmationToken,
|
||||
});
|
||||
setAuthCredentials(response);
|
||||
} catch (error) {
|
||||
throwErrorMessage(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const setNewPassword = async ({
|
||||
resetPasswordToken,
|
||||
password,
|
||||
confirmPassword,
|
||||
}) => {
|
||||
try {
|
||||
const response = await wootAPI.put('auth/password', {
|
||||
reset_password_token: resetPasswordToken,
|
||||
password_confirmation: confirmPassword,
|
||||
password,
|
||||
});
|
||||
setAuthCredentials(response);
|
||||
} catch (error) {
|
||||
throwErrorMessage(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const resetPassword = async ({ email }) =>
|
||||
wootAPI.post('auth/password', { email });
|
||||
6
app/javascript/v3/api/testimonials.js
Normal file
6
app/javascript/v3/api/testimonials.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import wootConstants from 'dashboard/constants/globals';
|
||||
import wootAPI from './apiClient';
|
||||
|
||||
export const getTestimonialContent = () => {
|
||||
return wootAPI.get(wootConstants.TESTIMONIAL_URL);
|
||||
};
|
||||
Reference in New Issue
Block a user