Skip to content

Commit

Permalink
Merge pull request #4 from Daniel-Alvarenga/main
Browse files Browse the repository at this point in the history
Finish Empresa Clients, Updated Recovery Method for Company Clients, Localization, and Schema Fixes
  • Loading branch information
VitorCarvalho67 authored May 17, 2024
2 parents fb4ba9a + ae68e1c commit 70ffc92
Show file tree
Hide file tree
Showing 27 changed files with 757 additions and 407 deletions.
2 changes: 1 addition & 1 deletion client/src/components/ContactUs.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<section class="contact-us">
<div class="box" id="box1">
<h1>Contact Us</h1>
<h1>Fale Conosco</h1>
<p>
Estamos comprometidos em oferecer soluções inovadoras e de qualidade que superem suas expectativas,
tornando sua experiência conosco memorável.
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<nav>
<ul>
<li>
<router-link to="/">About Us</router-link>
<router-link to="/">Sobre Nós</router-link>
</li>
<li>
<a href="https://github.com/VitorCarvalho67/Boot" target="_blank">GitHub</a>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ul>
</div>
</li>
<li><router-link to="/">About Us</router-link></li>
<li><router-link to="/">Sobre Nós</router-link></li>
<!-- <li><router-link to="/register">Cadastre-se Agora</router-link></li> -->
<li><router-link to="/login">Entrar</router-link></li>
</ul>
Expand Down
135 changes: 62 additions & 73 deletions client/src/router/guards/guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,120 +5,109 @@ import { authProfessor } from '../../services/api/professor';
import { authFuncionario } from '../../services/api/funcionario';
import { authEmpresa } from '../../services/api/empresa';

// isAuths
export async function isAuthAluno(){
var token = Cookies.get('token');
if (!token) {
return false;
} else {
try {
const response = await authAluno(token);
return (response.data == "Aluno autenticado com sucesso.") ? true : false
} catch (error) {
return false;
}
}
}

export async function isAuthAdmin() {
var token = Cookies.get('token-admin');
if (!token) {
return false;
} else {
try {
const response = await authAdmin(token);
if (response.data !== "Admin autenticado com sucesso.") {
return false;
} else {
return true;
}
return (response.data == "Admin autenticado com sucesso.") ? true : false
} catch (error) {
return false;
}
}
}

export async function isRegistering(){
return (Cookies.get('email-registro-aluno')) ? true : false;
}

export async function isRecoverigAluno(){
return (Cookies.get('email-recovery-aluno')) ? true : false;
}
}
}
}

export async function isAuthProfessor(){
var token = Cookies.get('token-professor');
export async function isAuthEmpresa(){
var token = Cookies.get('token-empresa');
if (!token) {
return false;
} else {
try {
const response = await authProfessor(token);
if (response.data !== "Professor autenticado com sucesso.") {
console.log("aaa");
return false;
} else {
return true;
}
const response = await authEmpresa(token);
return(response.data == "Empresa autenticada com sucesso.") ? true : false;
} catch (error) {
return false;
}
}
}

export async function isInitingProfessor(){
return (Cookies.get('email-init-professor')) ? true : false;
}

export async function isRecoverigProfessor(){
return (Cookies.get('email-recovery-professor')) ? true : false;
}

export async function isInitingFuncionario(){
return (Cookies.get('email-init-funcionario')) ? true : false;
}

export async function isRecoverigFuncionario(){
return (Cookies.get('email-recovery-funcionario')) ? true : false;
}

export async function isAuthFuncionario(){
var token = Cookies.get('token-funcionario');
if (!token) {
return false;
} else {
try {
const response = await authFuncionario(token);
if (response.data !== "Funcionário autenticado com sucesso.") {
console.log(response.data);
return false;
} else {
return true;
}
return (response.data == "Funcionário autenticado com sucesso.") ? true : false
} catch (error) {
return false;
}
}
}

export async function isAuthEmpresa(){
var token = Cookies.get('token-empresa');
export async function isAuthProfessor(){
var token = Cookies.get('token-professor');
if (!token) {
return false;
} else {
try {
const response = await authEmpresa(token);
if (response.data !== "Empresa autenticada com sucesso.") {
console.log(response.data);
return false;
} else {
return true;
}
const response = await authProfessor(token);
return (response.data == "Professor autenticado com sucesso.") ? true : false
} catch (error) {
return false;
}
}
}

export async function isAuthAluno(){
var token = Cookies.get('token');
if (!token) {
return false;
} else {
try {
const response = await authAluno(token);
if (response.data !== "Aluno autenticado com sucesso.") {
console.log(response.data);
return false;
} else {
return true;
}
} catch (error) {
return false;
}
}

// isRegisterings
export async function isRegistering(){
return (Cookies.get('email-registro-aluno')) ? true : false;
}

export async function isRegisteringEmpresa(){
return (Cookies.get('cnpj-registro-empresa')) ? true : false;
}

// isRecoverings
export async function isRecoveringAluno(){
return (Cookies.get('email-recovery-aluno')) ? true : false;
}

export async function isRecoveringEmpresa(){
return (Cookies.get('email-recovery-empresa')) ? true : false;
}

export async function isRecoveringFuncionario(){
return (Cookies.get('email-recovery-funcionario')) ? true : false;
}

export async function isRecoveringProfessor(){
return (Cookies.get('email-recovery-professor')) ? true : false;
}

// isInitings
export async function isInitingFuncionario(){
return (Cookies.get('email-init-funcionario')) ? true : false;
}

export async function isInitingProfessor(){
return (Cookies.get('email-init-professor')) ? true : false;
}
5 changes: 3 additions & 2 deletions client/src/router/routes/aluno.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import ValidateRecovery from '../../views/aluno/ValidateRecovery.vue';
import HomeAluno from '../../views/aluno/Home.vue';

import {
isRecoverigAluno,
isRecoveringAluno,
isRegistering,
isAuthAluno
} from '../guards/guards.js';

Expand Down Expand Up @@ -47,7 +48,7 @@ export const alunoRoutes = [
name: 'ValidateRecovery',
component: ValidateRecovery,
beforeEnter: async (to, from, next) => {
(await isRecoverigAluno()) ? next() : next("/recovery");
(await isRecoveringAluno()) ? next() : next("/recovery");
}
}
];
31 changes: 29 additions & 2 deletions client/src/router/routes/empresa.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { validateRecoveryEmpresa } from '../../services/api/empresa.js';
import Empresa from '../../views/empresa/Dashboard.vue';
import LoginEmpresa from '../../views/empresa/Login.vue';
import RecoveryEmpresa from '../../views/empresa/Recovery.vue';
import RegisterEmpresa from '../../views/empresa/Register.vue';
import ValidateEmpresa from '../../views/empresa/Validate.vue';
import ValidateRecoveryEmpresa from '../../views/empresa/ValidateRecovery.vue';

import {
isAuthEmpresa,
isRegisteringEmpresa,
isRecoveringEmpresa,
isAuthEmpresa
} from '../guards/guards.js';


Expand All @@ -21,9 +27,30 @@ export const empresaRoutes = [
name: "LoginEmpresa",
component: LoginEmpresa
},
{
path: "/empresa/register",
name: "RegistroEmpresa",
component: RegisterEmpresa
},
{
path: "/empresa/register/validate",
name: "ValidateEmpresa",
component: ValidateEmpresa,
beforeEnter: async (to, from, next) => {
(await isRegisteringEmpresa()) ? next() : next("/empresa/register");
}
},
{
path: "/empresa/recovery",
name: "RecoveryEmpresa",
component: RecoveryEmpresa
component: RecoveryEmpresa,
},
{
path: "/empresa/recovery/validate",
name: "ValidateRecoveryEmpresa",
component: ValidateRecoveryEmpresa,
beforeEnter: async (to, from, next) => {
(await isRecoveringEmpresa()) ? next() : next("/empresa/recovery");
}
}
]
4 changes: 2 additions & 2 deletions client/src/router/routes/funcionario.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ValidateRecoveryFuncionario from '../../views/funcionario/ValidateRecover
import {
isAuthFuncionario,
isInitingFuncionario,
isRecoverigFuncionario
isRecoveringFuncionario
} from '../guards/guards.js';

export const funcionarioRoutes = [
Expand Down Expand Up @@ -43,7 +43,7 @@ export const funcionarioRoutes = [
name: 'ValidateRecoveryFuncionario',
component: ValidateRecoveryFuncionario,
beforeEnter: async (to, from, next) => {
(await isRecoverigFuncionario()) ? next() : next("/funcionario/recovery");
(await isRecoveringFuncionario()) ? next() : next("/funcionario/recovery");
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions client/src/router/routes/professor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ValidateRecoveryProfessor from '../../views/professor/ValidateRecovery.vu
import {
isAuthProfessor,
isInitingProfessor,
isRecoverigProfessor,
isRecoveringProfessor,
} from '../guards/guards.js';

export const professorRoutes = [
Expand Down Expand Up @@ -43,7 +43,7 @@ export const professorRoutes = [
name: 'ValidateRecoveryProfessor',
component: ValidateRecoveryProfessor,
beforeEnter: async (to, from, next) => {
(await isRecoverigProfessor()) ? next() : next("/professor/recovery");
(await isRecoveringProfessor()) ? next() : next("/professor/recovery");
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion client/src/services/api/empresa.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const registerEmpresa = async (infoEmpresa) => {

export const validateEmpresa = async (infoEmpresa) => {
try {
const response = await api.post('empresa/validate/', infoEmpresa);
const response = await api.post('empresa/register/validate/', infoEmpresa);
return response;
} catch (error) {
return error.response.data;
Expand Down
11 changes: 5 additions & 6 deletions client/src/util/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const validateRecoveryMixin = {
if (!(/[A-Z]/.test(password))) this.alerts.alertUppercase = true;
else if (!(/[a-z]/.test(password))) this.alerts.alertLowercase = true;
else if (!(/[0-9]/.test(password))) this.alerts.alertNumber = true;
else if (!(/[*!@#$%&\./\\-]/.test(password))) this.alerts.alertSpecial = true;
else if (!(/[*!@#$%&\./\\-_]/.test(password))) this.alerts.alertSpecial = true;
else if (!(password.length >= 8)) this.alerts.alertLenght = true;

this.alerts.alertPass = false;
Expand All @@ -81,10 +81,8 @@ export const EmpresaMixin = {
event.preventDefault();
this.empresa.cnpjExibido = this.empresa.cnpjExibido.slice(0, cursorPosition - 1) + this.empresa.cnpjExibido.slice(cursorPosition);
return;
} else{
console.log(previousChar);
}
this.empresa.cnpj = this.empresa.cnpj.slice(0, cursorPosition - 1) + this.empresa.cnpj.slice(cursorPosition);
this.empresa.cnpj = this.empresa.cnpj.slice(0, cursorPosition - 1) + this.empresa.cnpj.slice(cursorPosition);
} else{
const cnpj = event.target.value.replace(/\D/g, '');

Expand All @@ -105,10 +103,11 @@ export const EmpresaMixin = {
event.target.value = cnpjFormatadoExibicao;

this.empresa.cnpj = cnpjFormatado;
console.log(cnpjFormatado);
this.empresa.cnpjExibido = cnpjFormatadoExibicao;
}

if (typeof this.cnpjValidate === 'function') {
this.cnpjValidate();
}
}
}
}
1 change: 0 additions & 1 deletion client/src/views/admin/RegisterFuncionario.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default {
this.token
);
console.log(response)
if (response.status >= 200 && response.status < 300) {
alert("Tudo certo! 😉");
Expand Down
6 changes: 3 additions & 3 deletions client/src/views/aluno/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

<div class="input-box password" :class="{ 'focused': focused.confirmFocused }">
<div class="d1">
<label for="confirmPassword">Confirmar Senha:</label>
<label for="confirmPassword">Confirmar senha</label>
<input :type="inputTypeConfirm" id="confirmPass" v-model="userAluno.confirmPassword"
@focus="focused.confirmFocused = true" @blur="focused.confirmFocused = false"
@input="checkConfirmPassword" required>
Expand Down Expand Up @@ -156,7 +156,7 @@ export default {
(/[A-Z]/.test(password)) &&
(/[a-z]/.test(password)) &&
(/[0-9]/.test(password)) &&
(/[*!@#$%&\./\\-]/.test(password)) &&
(/[*!@#$%&\./\\-_]/.test(password)) &&
(password.length >= 8) &&
(/@etec\.sp\.gov\.br$/.test(email)) &&
(password == passwordConfirm)
Expand Down Expand Up @@ -191,7 +191,7 @@ export default {
if (!(/[A-Z]/.test(password))) this.alerts.alertUppercase = true;
else if (!(/[a-z]/.test(password))) this.alerts.alertLowercase = true;
else if (!(/[0-9]/.test(password))) this.alerts.alertNumber = true;
else if (!(/[*!@#$%&\./\\-]/.test(password))) this.alerts.alertSpecial = true;
else if (!(/[*!@#$%&\./\\-_]/.test(password))) this.alerts.alertSpecial = true;
else if (!(password.length >= 8)) this.alerts.alertLenght = true;
this.checkConfirmPassword();
Expand Down
Loading

0 comments on commit 70ffc92

Please sign in to comment.