Commit bbde6ed7 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #13670 TIME 10:00 front login v2 + clean and code refactoring

parent 933fe160
......@@ -13,14 +13,27 @@
"options": {
"outputPath": "dist",
"index": "src/frontend/index.html",
"polyfills": "src/frontend/polyfills.ts",
"main": "src/frontend/main.ts",
"tsConfig": "src/frontend/tsconfig.app.json",
"styles": [],
"styles": [
"./node_modules/@fortawesome/fontawesome-free/css/all.min.css",
"./src/frontend/css/font-awesome-maarch/css/font-maarch.css",
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"./node_modules/jstree-bootstrap-theme/dist/themes/proton/style.min.css",
"./src/frontend/css/maarch-material.css",
"./src/frontend/css/engine.scss",
"./src/frontend/css/engine_2.scss",
"./node_modules/ng2-dnd/bundles/style.css"
],
"scripts": [
"node_modules/tinymce/tinymce.min.js",
"node_modules/hammerjs/hammer.js"
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/jstree-bootstrap-theme/dist/jstree.min.js",
"./node_modules/jquery.nicescroll/dist/jquery.nicescroll.min.js",
"node_modules/tinymce/tinymce.min.js"
],
"assets": [
"./src/frontend/assets",
{ "glob": "**/*", "input": "node_modules/tinymce/skins", "output": "/tinymce/skins/" },
{ "glob": "**/*", "input": "node_modules/tinymce/themes", "output": "/tinymce/themes/" },
{ "glob": "**/*", "input": "node_modules/tinymce/plugins", "output": "/tinymce/plugins/" }
......@@ -28,6 +41,12 @@
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "./src/frontend/environments/environment.ts",
"with": "./src/frontend/environments/environment.prod.ts"
}
],
"budgets": [
{
"type": "anyComponentStyle",
......@@ -63,7 +82,9 @@
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [],
"exclude": []
"exclude": [
"**/node_modules/**"
]
}
}
}
......
<?php
/*
* Copyright 2012-2017 Maarch
*
* This file is part of Maarch Framework.
*
* Maarch Framework is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
/****************************************************************************/
/* */
/* */
/* THIS PAGE CAN NOT BE OVERWRITTEN IN A CUSTOM */
/* */
/* */
/* **************************************************************************/
/**
* @brief Maarch root file
*
* @file
* @author Laurent Giovannoni <dev@maarch.org>
* @date $date$
* @version $Revision$
* @ingroup core
*/
require_once('core/class/class_functions.php');
include_once('core/init.php');
require_once('core/class/class_core_tools.php');
$func = new functions();
$core = new core_tools();
$_SESSION['custom_override_id'] = $core->get_custom_id();
/**** retrieve HTTP_REQUEST FROM SSO ****/
$_SESSION['HTTP_REQUEST'] = $_REQUEST;
if (!file_exists('installed.lck') && is_dir('install')) {
header('location: install/index.php');
exit;
}
if (isset($_GET['origin']) && $_GET['origin'] == 'scan') {
header('location: apps/'.$_SESSION['businessapps'][0]['appid'].'/reopen.php');
} else {
$_SESSION['config']['app_id'] = $_SESSION['businessapps'][0]['appid'];
header('location: '.$_SESSION['config']['coreurl'].'apps/'.$_SESSION['config']['app_id']
. '/index.php?display=true&page=login');
}
<script>
window.location.href = 'dist/index.html';
</script>
\ No newline at end of file
{
"name": "MaarchCourrier",
"version": "20.03.1",
"description": "MaarchCourrier",
"scripts": {
"build-css": "node-sass --include-path scss src/frontend/css/maarch-material.scss src/frontend/css/maarch-material.css --output-style compressed",
"build-prod": "ng build --prod && npm run build-css",
"build-watch": "ng build --watch",
"build": "ng build",
"postinstall": "ngcc",
"check-update": "ncu",
"dep-list": "npm list --depth=0",
"upgrade": "ncu -u",
......@@ -21,29 +21,7 @@
"author": "Maarch",
"license": "GPL-3.0",
"dependencies": {
"@fortawesome/fontawesome-free": "^5.13.0",
"@swimlane/ngx-charts": "^13.0.2",
"bootstrap": "^3.4.1",
"chosen-js": "^1.8.7",
"codelyzer": "^5.2.2",
"core-js": "^3.6.4",
"jquery": "^3.4.1",
"jquery-typeahead": "^2.11.0",
"jquery.nicescroll": "~3.7.6",
"jstree-bootstrap-theme": "^1.0.1",
"ng2-pdf-viewer": "^6.1.3",
"ngx-cookie-service": "^3.0.3",
"ngx-pipes": "^2.7.3",
"pdfjs-dist": "2.3.200",
"photoswipe": "^4.1.3",
"protractor": "^5.4.3",
"tinymce": "^5.2.1",
"tinymce-i18n": "^19.9.17",
"tooltipster": "^4.2.7",
"tslib": "^1.10.0",
"tslint": "^6.1.1",
"uglify-es": "3.3.9",
"uglifyjs-webpack-plugin": "2.2.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
......@@ -52,28 +30,51 @@
"@angular/cdk": "^9.2.0",
"@angular/cli": "^9.1.0",
"@angular/common": "^9.1.0",
"@angular/compiler": "^9.1.0",
"@angular/compiler-cli": "^9.1.0",
"@angular/compiler": "^9.1.0",
"@angular/core": "^9.1.0",
"@angular/forms": "^9.1.0",
"@angular/material": "^9.2.0",
"@angular/platform-browser": "^9.1.0",
"@angular/platform-browser-dynamic": "^9.1.0",
"@angular/platform-browser": "^9.1.0",
"@angular/platform-server": "^9.1.0",
"@angular/router": "^9.1.0",
"@fortawesome/fontawesome-free": "^5.13.0",
"@swimlane/ngx-charts": "^13.0.2",
"@types/datatables.net": "^1.10.18",
"@types/jquery.nicescroll": "^3.7.1",
"@types/jquery": "^3.3.34",
"@types/node": "^13.11.0",
"@types/jstree": "^3.3.39",
"@types/tooltipster": "0.0.29",
"ajv": "^6.12.0",
"bootstrap": "^3.4.1",
"chosen-js": "^1.8.7",
"codelyzer": "^5.2.2",
"hammerjs": "^2.0.8",
"html-minifier": "^4.0.0",
"jquery-typeahead": "^2.11.0",
"jquery.nicescroll": "^3.7.6",
"jquery": "^3.4.1",
"jstree-bootstrap-theme": "^1.0.1",
"ng2-dnd": "^5.0.2",
"ng2-pdf-viewer": "^6.1.3",
"ngx-cookie-service": "^3.0.3",
"ngx-pipes": "^2.7.3",
"node-sass": "^4.13.1",
"nodemon": "^2.0.2",
"npm-check-updates": "^4.1.1",
"pdfjs-dist": "2.3.200",
"photoswipe": "^4.1.3",
"protractor": "^5.4.3",
"rxjs": "^6.5.5",
"tinymce-i18n": "^19.9.17",
"tinymce": "^5.2.1",
"tooltipster": "^4.2.7",
"tslib": "^1.10.0",
"tslint": "^6.1.1",
"typescript": "3.8.3",
"uglify-es": "3.3.9",
"uglifyjs-webpack-plugin": "2.2.0",
"url-loader": "^4.0.0",
"webpack": "^4.42.1"
},
......
......@@ -33,7 +33,8 @@ $app->add(function (\Slim\Http\Request $request, \Slim\Http\Response $response,
$currentMethod = empty($route) ? '' : $route->getMethods()[0];
$currentRoute = empty($route) ? '' : $route->getPattern();
if (!in_array($currentMethod.$currentRoute, \SrcCore\controllers\AuthenticationController::ROUTES_WITHOUT_AUTHENTICATION)) {
$login = \SrcCore\controllers\AuthenticationController::authentication();
$authorizationHeaders = $request->getHeader('Authorization');
$login = \SrcCore\controllers\AuthenticationController::authentication($authorizationHeaders);
if (!empty($login)) {
\SrcCore\controllers\CoreController::setGlobals(['login' => $login]);
if (!empty($currentRoute)) {
......
......@@ -33,7 +33,7 @@ class AuthenticationController
const MAX_DURATION_TOKEN = 30; //Minutes
const ROUTES_WITHOUT_AUTHENTICATION = [
'GET/authenticationInformations', 'GET/images', 'POST/password', 'PUT/password', 'GET/passwordRules',
'GET/jnlp/{jnlpUniqueId}', 'GET/onlyOffice/mergedFile', 'POST/onlyOfficeCallback'
'GET/jnlp/{jnlpUniqueId}', 'GET/onlyOffice/mergedFile', 'POST/onlyOfficeCallback', 'POST/authenticate'
];
public function getInformations(Request $request, Response $response)
......@@ -47,7 +47,7 @@ class AuthenticationController
return $response->withJson(['instanceId' => null, 'applicationName' => $appName, 'loginMessage' => $parameter['param_value_string'] ?? null]);
}
public static function authentication()
public static function authentication($authorizationHeaders = [])
{
$userId = null;
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
......@@ -63,31 +63,33 @@ class AuthenticationController
}
}
} else {
$cookie = AuthenticationModel::getCookieAuth();
if (!empty($cookie) && AuthenticationModel::cookieAuthentication($cookie)) {
AuthenticationModel::setCookieAuth(['userId' => $cookie['userId']]);
$userId = $cookie['userId'];
}
// if (!empty($authorizationHeaders)) {
// $token = null;
// foreach ($authorizationHeaders as $authorizationHeader) {
// if (strpos($authorizationHeader, 'Bearer') === 0) {
// $token = str_replace('Bearer ', '', $authorizationHeader);
// }
// }
// if (!empty($token)) {
// try {
// $jwt = (array)JWT::decode($token, CoreConfigModel::getEncryptKey(), ['HS256']);
// } catch (\Exception $e) {
// return null;
// }
// $jwt['user'] = (array)$jwt['user'];
// if (!empty($jwt) && !empty($jwt['user']['id'])) {
// $id = $jwt['user']['id'];
// }
// }
// }
// $cookie = AuthenticationModel::getCookieAuth();
// if (!empty($cookie) && AuthenticationModel::cookieAuthentication($cookie)) {
// AuthenticationModel::setCookieAuth(['userId' => $cookie['userId']]);
// $userId = $cookie['userId'];
// }
if (!empty($authorizationHeaders)) {
$token = null;
foreach ($authorizationHeaders as $authorizationHeader) {
if (strpos($authorizationHeader, 'Bearer') === 0) {
$token = str_replace('Bearer ', '', $authorizationHeader);
}
}
if (!empty($token)) {
try {
$jwt = (array)JWT::decode($token, CoreConfigModel::getEncryptKey(), ['HS256']);
} catch (\Exception $e) {
return null;
}
$jwt['user'] = (array)$jwt['user'];
if (!empty($jwt) && !empty($jwt['user']['id'])) {
$id = $jwt['user']['id'];
$user = UserModel::getById(['select' => ['user_id'], 'id' => $id]);
$userId = $user['user_id'];
}
}
}
}
if (!empty($userId)) {
......@@ -178,7 +180,7 @@ class AuthenticationController
if (!$check) {
return $response->withStatus(400)->withJson(['errors' => 'Bad Request']);
}
var_dump('ttotoi');
$login = strtolower($body['login']);
$authenticated = AuthenticationModel::authentication(['login' => $login, 'password' => $body['password']]);
if (empty($authenticated)) {
......@@ -215,14 +217,14 @@ class AuthenticationController
$response = $response->withHeader('Token', AuthenticationController::getJWT());
$response = $response->withHeader('Refresh-Token', $refreshToken);
HistoryController::add([
/* HistoryController::add([
'tableName' => 'users',
'recordId' => $user['id'],
'eventType' => 'LOGIN',
'info' => _LOGIN . ' : ' . $login,
'moduleId' => 'authentication',
'eventId' => 'login'
]);
]); */
return $response->withStatus(204);
}
......
......@@ -148,7 +148,7 @@ class CoreController
$pathInfo = pathinfo($path);
$response->write($fileContent);
$response = $response->withAddedHeader('Content-Disposition', "attachment; filename=maarch.{$pathInfo['extension']}");
$response = $response->withAddedHeader('Content-Disposition', "inline; filename=maarch.{$pathInfo['extension']}");
return $response->withHeader('Content-Type', $mimeType);
}
......
......@@ -72,7 +72,7 @@
</ul>
<p>&nbsp;</p>
<div class="img_credits_maarch_box">
<img src="static.php?filename=maarch_box.png" />
<mat-icon svgIcon="maarchBox" style="width: 100%;height: auto;"></mat-icon>
</div>
</div>
</mat-card>
......
......@@ -2,13 +2,10 @@ import { Component, OnInit } from '@angular/core';
import { LANG } from './translate.component';
import { HeaderService } from '../service/header.service';
import { AppService } from '../service/app.service';
declare function $j(selector: any): any;
declare var angularGlobals: any;
import { environment } from '../environments/environment';
@Component({
templateUrl: "about-us.component.html",
templateUrl: 'about-us.component.html',
styleUrls: ['about-us.component.css'],
providers: [AppService]
})
......@@ -21,14 +18,12 @@ export class AboutUsComponent implements OnInit {
constructor(
private headerService: HeaderService,
public appService: AppService) {
$j("link[href='merged_css.php']").remove();
}
public appService: AppService) { }
ngOnInit(): void {
this.headerService.setHeader(this.lang.aboutUs);
this.applicationVersion = angularGlobals.applicationVersion;
this.applicationVersion = environment.VERSION;
this.loading = false;
}
}
......@@ -5,15 +5,16 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { HttpClient } from '@angular/common/http';
import { DiffusionsListComponent } from '../../diffusions/diffusions-list.component';
import { FormControl } from '@angular/forms';
import { Observable, of } from 'rxjs';
import { startWith } from 'rxjs/internal/operators/startWith';
import { map, tap, finalize, catchError } from 'rxjs/operators';
import { NoteEditorComponent } from '../../notes/note-editor.component';
import { Observable } from 'rxjs/internal/Observable';
import { of } from 'rxjs/internal/observable/of';
declare function $j(selector: any): any;
declare var $: any;
@Component({
templateUrl: "redirect-action.component.html",
templateUrl: 'redirect-action.component.html',
styleUrls: ['redirect-action.component.scss'],
})
export class RedirectActionComponent implements OnInit {
......@@ -50,7 +51,7 @@ export class RedirectActionComponent implements OnInit {
ngOnInit(): void {
let noEntity = true;
this.loading = true;
this.http.get("../../rest/resourcesList/users/" + this.data.userId + "/groups/" + this.data.groupId + "/baskets/" + this.data.basketId + "/actions/" + this.data.action.id + "/getRedirect")
this.http.get('../../rest/resourcesList/users/' + this.data.userId + '/groups/' + this.data.groupId + '/baskets/' + this.data.basketId + '/actions/' + this.data.action.id + '/getRedirect')
.subscribe((data: any) => {
this.entities = data['entities'];
this.userListRedirect = data.users;
......@@ -66,10 +67,10 @@ export class RedirectActionComponent implements OnInit {
}
});
if (this.userListRedirect.length == 0 && noEntity) {
if (this.userListRedirect.length === 0 && noEntity) {
this.redirectMode = 'none';
this.loading = false;
} else if (this.userListRedirect.length == 0 && !noEntity) {
} else if (this.userListRedirect.length === 0 && !noEntity) {
this.loadEntities();
} else if (this.userListRedirect.length > 0 && noEntity) {
this.loadDestUser();
......@@ -84,15 +85,15 @@ export class RedirectActionComponent implements OnInit {
loadEntities() {
this.redirectMode = 'entity';
if (this.data.resIds.length == 1) {
if (this.data.resIds.length === 1) {
this.injectDatasParam.resId = this.data.resIds[0];
}
this.loading = false;
setTimeout(() => {
$j('#jstree').jstree({
"checkbox": {
$('#jstree').jstree({
'checkbox': {
'deselect_all': true,
"three_state": false //no cascade selection
'three_state': false // no cascade selection
},
'core': {
force_text: true,
......@@ -103,29 +104,29 @@ export class RedirectActionComponent implements OnInit {
'multiple': false,
'data': this.entities,
},
"plugins": ["checkbox", "search", "sort"]
'plugins': ['checkbox', 'search', 'sort']
});
var to: any = false;
$j('#jstree_search').keyup(function () {
let to: any = false;
$('#jstree_search').keyup(function () {
if (to) { clearTimeout(to); }
to = setTimeout(function () {
var v = $j('#jstree_search').val();
$j('#jstree').jstree(true).search(v);
const v: any = $('#jstree_search').val();
$('#jstree').jstree(true).search(v);
}, 250);
});
$j('#jstree')
$('#jstree')
// listen for event
.on('select_node.jstree', (e: any, data: any) => {
this.selectEntity(data.node.original);
}).on('deselect_node.jstree', (e: any, data: any) => {
$j('#jstree').jstree('select_node', data.node.original);
$('#jstree').jstree('select_node', data.node.original);
})
// create the instance
.jstree();
}, 0);
setTimeout(() => {
$j('#jstree').jstree('select_node', this.currentEntity);
$('#jstree').jstree('select_node', this.currentEntity);
this.selectEntity(this.currentEntity);
}, 200);
......@@ -140,43 +141,42 @@ export class RedirectActionComponent implements OnInit {
);
this.loading = false;
if (this.data.resIds.length == 1) {
this.http.get("../../rest/resources/" + this.data.resIds[0] + "/listInstance").subscribe((data: any) => {
if (this.data.resIds.length === 1) {
this.http.get('../../rest/resources/' + this.data.resIds[0] + '/listInstance').subscribe((data: any) => {
this.diffusionListDestRedirect = data.listInstance;
Object.keys(data).forEach(diffusionRole => {
data[diffusionRole].forEach((line: any) => {
if (line.item_mode == 'dest') {
if (line.item_mode === 'dest') {
this.oldUser = line;
}
});
});
$j('.searchUserRedirect').click();
$('.searchUserRedirect').click();
}, (err: any) => {
this.notify.handleErrors(err);
});
} else {
this.keepDestForRedirection = false;
setTimeout(() => {
$j('.searchUserRedirect').click();
$('.searchUserRedirect').click();
}, 200);
}
}
changeDest(event: any) {
this.currentDiffusionListDestRedirect = this.diffusionListDestRedirect
let user = event.option.value;
this.currentDiffusionListDestRedirect = this.diffusionListDestRedirect;
const user = event.option.value;
this.destUser = {
difflist_type: "entity_id",
item_mode: "dest",
item_type: "user_id",
difflist_type: 'entity_id',
item_mode: 'dest',
item_type: 'user_id',
item_id: user.user_id,
labelToDisplay: user.labelToDisplay,
descriptionToDisplay: user.descriptionToDisplay
};
if (this.data.resIds.length == 1) {
if (this.data.resIds.length === 1) {
this.isDestinationChanging = false;
this.http.get('../../rest/resources/' + this.data.resIds[0] + '/users/' + user.id + '/isDestinationChanging')
.subscribe((data: any) => {
......@@ -189,7 +189,7 @@ export class RedirectActionComponent implements OnInit {
let isInCopy = false;
let newCopy = null;
this.currentDiffusionListDestRedirect.forEach((element: any) => {
if (element.item_mode == 'cc' && element.item_id == this.oldUser.item_id) {
if (element.item_mode === 'cc' && element.item_id === this.oldUser.item_id) {
isInCopy = true;
}
});
......@@ -200,14 +200,14 @@ export class RedirectActionComponent implements OnInit {
this.currentDiffusionListDestRedirect.push(newCopy);
}
}
this.currentDiffusionListDestRedirect.splice(this.currentDiffusionListDestRedirect.map((e: any) => { return e.item_mode; }).indexOf('dest'), 1);
this.currentDiffusionListDestRedirect.splice(this.currentDiffusionListDestRedirect.map((e: any) => e.item_mode).indexOf('dest'), 1);
} else {
this.isDestinationChanging = true;
}
this.currentDiffusionListDestRedirect.push(this.destUser);
this.userRedirectCtrl.reset();
$j('.searchUserRedirect').blur();
$('.searchUserRedirect').blur();
}
private _filterUserRedirect(value: string): any[] {
......@@ -230,7 +230,7 @@ export class RedirectActionComponent implements OnInit {
}
executeAction() {
if (this.redirectMode == 'user') {
if (this.redirectMode === 'user') {
this.http.put(this.data.processActionRoute, { resources: this.data.resIds, data: { onlyRedirectDest: true, listInstances: this.currentDiffusionListDestRedirect }, note: this.noteEditor.getNote() }).pipe(
tap((data: any) => {
if (data && data.errors != null) {
......@@ -263,9 +263,9 @@ export class RedirectActionComponent implements OnInit {
}
checkValidity() {
if (this.redirectMode == 'entity' && this.appDiffusionsList && this.appDiffusionsList.getDestUser().length > 0 && this.currentEntity.serialId > 0 && !this.loading) {
if (this.redirectMode === 'entity' && this.appDiffusionsList && this.appDiffusionsList.getDestUser().length > 0 && this.currentEntity.serialId > 0 && !this.loading) {
return false;
} if (this.redirectMode == 'user' && this.currentDiffusionListDestRedirect.length > 0 && this.destUser != null && !this.loading) {
} if (this.redirectMode === 'user' && this.currentDiffusionListDestRedirect.length > 0 && this.destUser != null && !this.loading) {
return false;
} else {
return true;