Skip to content

Commit

Permalink
Implement symlink, crazyAuth and update Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
kekefreedog committed Apr 22, 2024
1 parent fb9f7e0 commit 8438630
Show file tree
Hide file tree
Showing 9 changed files with 725 additions and 11 deletions.
12 changes: 6 additions & 6 deletions docs/NewProject.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Open a terminal and go on the directory where you want create your project (Exem

- [ ] Check [PHP](https://www.php.net/) version is >= 8.2 by using :

```sh {"id":"01HQDDF3C07BXVQ0PTJKW5NSWW"}
```sh
php -v
# PHP 8.3.0RC3 (cli) (built: Oct 2 2023 09:38:17) (NTS)
```

- [ ] Check [Composer](https://getcomposer.org/) version is >= 2.5.8 by using :

```sh {"id":"01HQDDF3C07BXVQ0PTJMHR6M50"}
```sh
composer -V
# Composer version 2.5.8 2023-05-24 15:00:39
```
Expand All @@ -22,7 +22,7 @@ composer -V

- [ ] Install last version of [CrazyPHP](https://github.com/kekefreedog/CrazyPHP) by using :

```sh {"id":"01HQDDF3C07BXVQ0PTJP6NNGWV"}
```sh
composer require kzarshenas/crazyphp
```

Expand All @@ -32,7 +32,7 @@ composer require kzarshenas/crazyphp

> If you are using OS Windows, make sure to execute `npm i` into the CrazyPHP folder
```json {"id":"01HQDDF3C07BXVQ0PTJS0562AD"}
```json
{
"require": {
"kzarshenas/crazyphp": "@dev"
Expand All @@ -53,13 +53,13 @@ composer require kzarshenas/crazyphp
And then execute the command below in the terminal :

```sh {"id":"01HQDDF3C07BXVQ0PTJWJD40WV"}
```sh
composer update
```

- [ ] Execute the new project cli command by using :

```sh {"id":"01HQDDF3C07BXVQ0PTJXFK2VNA"}
```sh
php vendor/kzarshenas/crazyphp/bin/CrazyCommand new project
# 🎉 New project created with success 🎉
```
Expand Down
169 changes: 169 additions & 0 deletions resources/Extensions/CrazyAuth/Scripts/Interface/AuthInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?php declare(strict_types=1);
/**
* Crazy Auth Interface
*
* PHP version 8.1.2
*
* @package kzarshenas/crazyphp
* @author kekefreedog <[email protected]>
* @copyright 2022-2024 Kévin Zarshenas
*/
namespace App\Core;

/**
* Dependances
*/
use CrazyPHP\Library\Exception\ExceptionResponse;
use App\Core\CredentialInterface;
use App\Core\UserInterface;

/**
* Auth Interface
*
* Interface for authentification
*
* @source https://github.com/PHPAuth/PHPAuth/blob/master/sources/AuthInterface.php
*
* @package kzarshenas/crazyphp
* @author kekefreedog <[email protected]>
* @copyright 2022-2024 Kévin Zarshenas
*/
interface AuthInterface {

/**
* Constructor
*
* @param CredentialInterface $credentials
* @param ?UserInterface $user (Null means you are registering a new user)
* @param array $options
* @param self
*/
public function __construct(CredentialInterface $credentials, ?UserInterface $user = null, array $options = []);

/** Public method | Action
******************************************************
*/

/**
* Register
*
* Register new user
*
* @return self
*/
public function register():self;

/**
* Login
*
* Login existing user
*
* @return self
*/
public function login():self;

/**
* Logout
*
* Logout existing user
*
* @return self
*/
public function logout():self;

/**
* Logout
*
* Logout all user
*
* @return self
*/
public function logoutAll():self;

/**
* Activate
*
* Activate existing user
*
* @return self
*/
public function activate():self;

/**
* Delete
*
* Delete existing user
*
* @return self
*/
public function delete():self;

/**
* Change Email
*
* Change email of existing user
*
* @return self
*/
public function changeEmail();

/**
* Change Password
*
* Change password of existing user
*
* @return self
*/
public function changePassword();


/** Public method | Validator
******************************************************
*/

/**
* Is User Connected
*
* Check if user is connected
*
* @return bool
*/
public function isUserConnected():bool;

/**
* Is User Valid
*
* Check if user is valid
*
* @return bool
*/
public function isUserValid():bool;

/**
* Is User Locked
*
* Check if user is locked
*
* @return bool
*/
public function isUserLocked():bool;

/** Public method | Get
******************************************************
*/

/**
* Get UID
*
* Get unique ID of the auth
*/
public function getUID():int;

/**
* Get user
*
* @return ?UserInterface
*/
public function getUser():?UserInterface;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php declare(strict_types=1);
/**
* Crazy Auth Interface
*
* PHP version 8.1.2
*
* @package kzarshenas/crazyphp
* @author kekefreedog <[email protected]>
* @copyright 2022-2024 Kévin Zarshenas
*/
namespace App\Core;

/**
* Dependances
*/
use CrazyPHP\Library\Exception\ExceptionResponse;
use App\Core\UserInterface;

/**
* Credential Interface
*
* Interface for credential
*
* @package kzarshenas/crazyphp
* @author kekefreedog <[email protected]>
* @copyright 2022-2024 Kévin Zarshenas
*/
interface CredentialInterface {

/**
* Constructor
*
* @param array $form
* @param array $options
* @param self
*/
public function __construct(array $form, array $options = []);

/** Public method | Validator
******************************************************
*/

/**
* Is Email Taken
*
* Check if email is already given
*
* @return bool
*/
public function isEmailTaken():bool;

}
114 changes: 114 additions & 0 deletions resources/Extensions/CrazyAuth/Scripts/Interface/UserInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php declare(strict_types=1);
/**
* Crazy Auth Interface
*
* PHP version 8.1.2
*
* @package kzarshenas/crazyphp
* @author kekefreedog <[email protected]>
* @copyright 2022-2024 Kévin Zarshenas
*/
namespace App\Core;

/**
* Dependances
*/
use CrazyPHP\Library\Exception\ExceptionResponse;

/**
* User Interface
*
* Interface for users
*
* @package kzarshenas/crazyphp
* @author kekefreedog <[email protected]>
* @copyright 2022-2024 Kévin Zarshenas
*/
interface UserInterface {

/** Public method | Get
******************************************************
*/

/**
* Get User Identifier
*
* The public representation of the user (e.g. a username, an email address, etc.)
*
* @return string
*/
public function getUserIdentifier():string;

/**
* Get Id
*
* @return ?int
*/
public function getId():?int;

/**
* Get Email
*
* @return ?string
*/
public function getEmail():?string;

/**
* Get Roles
*
* Returns the roles granted to the user.
*
* @return array
*/
public function getRoles():array;

/**
* Get Password
*
* @return string
*/
public function getPassword():string;

/**
* Set Lock
*
* @return string
*/
public function setLock():string;

/** Public method | Set
******************************************************
*/

/**
* Set Email
*
* @param string $email
* @return self
*/
public function setEmail(string $email):self;

/**
* Set Password
*
* @param string $password
* @return self
*/
public function setPassword(string $password):self;

/**
* Set Roles
*
* @param array $roles
* @return self
*/
public function setRoles(array $roles):self;

/**
* Get Lock
*
* @return string
*/
public function getLock():string;

}
Loading

0 comments on commit 8438630

Please sign in to comment.