Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Gestion and Apis #1 (#4)
Browse files Browse the repository at this point in the history
* essais validator

* test de bdd

* valdation and console back

* bdd gestion

* discord init

* Discord and change route ATC

* add bootstrap

* register

* discord and page training

* validation donées form

* users database

* test de database

* session serveur

* whiteList creat

* whitelist controller and database

* testing

* gestion des logs

* des test

* Modification Auth

* slug

* modification visuelle

* mise en place admins systeme

* page modo and admin users

* api sanct

* mods API

* Request APi keys page

* api keys suite

* test

* test2

* test3

Signed-off-by: Alexandre Caussades <alexaussades@gmail.com>

* test4

* test5

* test7

* test8

* update API Serveur

---------

Signed-off-by: Alexandre Caussades <alexaussades@gmail.com>
Co-authored-by: Alexandre Caussades <alexaussades@gmail.com>
  • Loading branch information
alexcaussades and Alexandre Caussades authored May 20, 2023
1 parent 815d242 commit 1707785
Show file tree
Hide file tree
Showing 63 changed files with 3,041 additions and 235 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ yarn-error.log
/.fleet
/.idea
/.vscode
composer.lock
composer.lock
93 changes: 93 additions & 0 deletions app/Http/Controllers/ApiGestionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace App\Http\Controllers;

use App\Models\ApiUsers;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class ApiGestionController extends Controller
{

public function Create_client_id(){
$sclient_id = Str::random(15);
return $sclient_id;
}

public function Create_client_secret(){
$token = Str::random(26);
return $token;
}

public function lvl_users(){
$lvl = auth()->user()->role;
if($lvl == 1 || $lvl == 2 || $lvl == 3){
$lvl_users = "1";
}
if($lvl == 4 || $lvl == 5 || $lvl == 6){
$lvl_users = "2";
}
if($lvl == 7 || $lvl == 8){
$lvl_users = "3";
}
if($lvl == 9 || $lvl == 10){
$lvl_users = "4";
}
return $lvl_users;
}

public function return_information(){
$information = array(
"client_id" => $this->Create_client_id(),
"token" => $this->Create_client_secret(),
"role" => $this->lvl_users(),
);
return $information;
}

public function check_Informations($id){

$check = ApiUsers::where('users_id', $id)->first();
if($check != null){
return $check;
}else{
$information = array(
"role" => 0,
);
return $information;
}
}

public function creat_keys_api(){
$information = $this->return_information();
$api = new ApiUsers();
$api->client_id = $information['client_id'];
$api->token = $information['token'];
$api->users_id = auth()->user()->id;
$api->email = auth()->user()->email;
$api->role = $information['role'];
$api->save();
return $information;
}

public function get_keys_api(){
$information = $this->check_Informations(auth()->user()->id);
if($information['visible'] == true){

}
return $information;
}

public function delete_keys_api(){
$api = ApiUsers::where('users_id', auth()->user()->id)->first();
$api->delete();

}

Public function update_visible(){
$api = ApiUsers::where('users_id', auth()->user()->id)->first();
$api->visible = false;
$api->save();
}
}
29 changes: 22 additions & 7 deletions app/Http/Controllers/AtcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,37 @@
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class AtcController extends Controller
{
function new(){

function new()
{

return response()->json([
"status" => "success"
]);
}

function add(Request $request){
function add(Request $request)
{
$vid = $request->input("vid");

return response()->json([
"status" => "success",
"vid" => $vid
$validateur = Validator::make($request->all(), [
'vid' => 'required|min:6|integer'
]);
//dd($validateur->fails());
if ($validateur->fails()) {
return response()->json([
"status" => "error",
"message" => "vid invalide"
]);
} else {
return response()->json([
"status" => "success",
"vid" => $vid
]);
}
}


}
22 changes: 22 additions & 0 deletions app/Http/Controllers/AutAdminController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace App\Http\Controllers;

use App\Models\Admin;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AutAdminController extends Controller
{
protected $guard = "admin";

// creation function in laravel activation session for admin via email adresse check

public function check_admin(Request $request)
{
$admin = Admin::where('email', $request->email)->first();
if ($admin) {
return Auth::guard('admin')->attempt(['email' => $request->email]);
}
}
}
11 changes: 11 additions & 0 deletions app/Http/Controllers/AutModoController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;

class AutModoController extends Controller
{
protected $guard = "modo";
}
59 changes: 59 additions & 0 deletions app/Http/Controllers/DiscordNotfyController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;

class DiscordNotfyController extends Controller
{


public function index()
{
return $this->PostNotify();
}

public function PostNotify2()
{
$reponse = Http::post("https://discord.com/api/webhooks/1095038427973558433/DFUjcyw9kMDlcB2N-XCsKQrr2hJpGzQN_YDik1H4oqplDNPOl1usJlBL7I9z_O3Kko-9", [
"embeds" => [
[
"title" => "Ceci est un test pour le webhook et les notifications discord pour les feactures de l'application",
"description" => "Bonjour tout le monde, je suis un test pour le webhook et les notifications discord pour les feactures de l'application, pour plus d'information veuillez contacter le developpeur de l'application ou le support technique de l'application.",
"color" => 16711680
]
]
]);
return $reponse->json();
}


public function PostNotify()
{
$reponse = Http::post("https://discord.com/api/webhooks/1094916096324284477/Ulamwc2-t-asqRJyPabHwKuJ0Eel0_1hqphweOiIaLzoRQFr3vScn1Zv40xp7XAMu4Q3", [
"embeds" => [
[
"title" => "test",
"description" => "test",
"color" => 16711680
]
]
]);
return $reponse->json();
}

public function newAddWhiteList($nameRp, $discordName, $email)
{
$reponse = Http::post("https://discord.com/api/webhooks/1095038427973558433/DFUjcyw9kMDlcB2N-XCsKQrr2hJpGzQN_YDik1H4oqplDNPOl1usJlBL7I9z_O3Kko-9", [
"embeds" => [
[
"title" => "Ajout de la liste d'attente de la whitelist de " . $nameRp,
"description" => "l'utilisateur " . $nameRp . " a fait une demande d'ajout sur la liste d'attente de la whitelist du serveur. sont UsersName Discord est : " . $discordName . "\n Adresse email : " . $email . "\n URL de la demande : https://127.0.0.1:8000/whitelist/LudivicRamirez/34/",
"color" => 16711680
]
]
]);
return $reponse->json();
}
}
32 changes: 32 additions & 0 deletions app/Http/Controllers/RolesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class RolesController extends Controller
{
public function new()
{
return view("roles.new");
}

public function create($name, $information)
{
$roles = new \App\Models\roles();
$roles->create_Roles($name, $information);
return $roles;
}

public function get_all()
{
$roles = new \App\Models\roles();
return $roles->get_all();
}

public function get($id)
{
$roles = new \App\Models\roles();
return $roles->get($id);
}
}
Loading

0 comments on commit 1707785

Please sign in to comment.