Skip to content
Snippets Groups Projects
Unverified Commit 3d7d3ae0 authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

Improve approve decline workflow (#4652)

parent 5060366a
Branches
Tags
No related merge requests found
......@@ -89,6 +89,10 @@
"upload_avatar": "Upload Avatar",
"delete_avatar": "Delete Avatar",
"crop_avatar": "Crop Your Avatar"
},
"pending": {
"title": "Pending Registration",
"message": "Thank you for registering! Your account is currently pending approval by an administrator."
}
},
"room": {
......@@ -374,7 +378,7 @@
"invalid_invite": "Your invitation token is either invalid or incorrect. Please contact your administrator to receive a new one",
"email_exists": "An account under this email already exists. Please try again with another email",
"old_password": "The current password you have entered is incorrect",
"pending": "Your registration is pending approval",
"pending": "Your registration is pending approval from your administrator",
"banned": "You do not have access to this application. Please contact your administrator if you believe this is a mistake"
},
"rooms": {
......
......@@ -34,12 +34,15 @@ class ExternalController < ApplicationController
user.save! if user.changed?
end
# Set to pending if registration method is approval
if registration_method == SiteSetting::REGISTRATION_METHODS[:approval]
user.pending! if new_user
return redirect_to '/pending' if user.pending?
end
user.generate_session_token!
session[:session_token] = user.session_token
# Set to pending if registration method is approval
user.pending! if new_user && registration_method == SiteSetting::REGISTRATION_METHODS[:approval]
# TODO: - Ahmad: deal with errors
redirect_location = cookies[:location]
cookies.delete(:location)
......
......@@ -13,8 +13,8 @@ export default function App() {
const location = useLocation();
// Pages that do not need a header: SignIn, SignUp and JoinMeeting (if the user is not signed in)
const headerPage = location.pathname !== '/signin' && location.pathname !== '/signup' && !location.pathname.includes('/join');
const pageHeight = (headerPage || currentUser.signed_in) ? 'regular-height' : 'no-header-height';
const homePage = location.pathname === '/';
const pageHeight = (homePage || currentUser.signed_in) ? 'regular-height' : 'no-header-height';
// i18n
const { i18n } = useTranslation();
......@@ -32,7 +32,7 @@ export default function App() {
return (
<>
{(headerPage || currentUser.signed_in) && <Header /> }
{(homePage || currentUser.signed_in) && <Header /> }
<Container className={pageHeight}>
<Outlet />
</Container>
......
import React from 'react';
import { Card } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import Logo from '../../shared_components/Logo';
import ButtonLink from '../../shared_components/utilities/ButtonLink';
export default function PendingRegistration() {
const { t } = useTranslation();
return (
<div className="vertical-buffer">
<div className="text-center pb-4">
<Logo />
</div>
<Card className="col-md-4 mx-auto p-4 border-0 shadow-sm text-center">
<Card.Title className="pb-2 fs-1 text-danger">{ t('user.pending.title') }</Card.Title>
<span className="mb-3">{ t('user.pending.message') }</span>
<ButtonLink to="/" variant="brand" className="btn btn-lg m-2">
{t('return_home')}
</ButtonLink>
</Card>
</div>
);
}
......@@ -28,7 +28,7 @@ export default function useCreateSession() {
},
onError: (err) => {
if (err.response.data.errors === 'PendingUser') {
toast.error(t('toast.error.users.pending'));
navigate('/pending');
} else if (err.response.data.errors === 'BannedUser') {
toast.error(t('toast.error.users.banned'));
} else {
......
......@@ -34,6 +34,7 @@ import UnauthenticatedOnly from './routes/UnauthenticatedOnly';
import AuthenticatedOnly from './routes/AuthenticatedOnly';
import DefaultErrorPage from './components/errors/DefaultErrorPage';
import NotFoundPage from './components/errors/NotFoundPage';
import PendingRegistration from './components/users/registration/PendingRegistration';
const queryClientConfig = {
defaultOptions: {
......@@ -58,6 +59,7 @@ const router = createBrowserRouter(
<Route path="/signup" element={<Signup />} />
<Route path="/signin" element={<SignIn />} />
<Route path="/forget_password" element={<ForgetPassword />} />
<Route path="/pending" element={<PendingRegistration />} />
</Route>
<Route element={<AuthenticatedOnly />}>
......
......@@ -17,12 +17,13 @@ export default function AuthenticatedOnly() {
// User is either pending or banned
if (currentUser.signed_in && currentUser.status !== 'active') {
deleteSession.mutate();
if (currentUser.status === 'pending') {
toast.error(t('toast.error.users.pending'));
} else {
toast.error(t('toast.error.users.banned'));
}
return deleteSession.mutate();
}
if (currentUser.signed_in && !currentUser?.verified) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment