-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update dependencies * Create jobs table * Update SDK dependency * Updates to auth * Fix auth * Fix authentication namespace bug * Update docs
- Loading branch information
1 parent
57d4323
commit 6143241
Showing
76 changed files
with
943 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Set the base image for subsequent instructions | ||
FROM php:7.2 | ||
|
||
# Update packages | ||
RUN apt-get update | ||
|
||
# Install PHP and composer dependencies | ||
RUN apt-get install -qq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev | ||
|
||
# Clear out the local repository of retrieved package files | ||
RUN apt-get clean | ||
|
||
# Install needed extensions | ||
# Here you can install any other extension that you need during the test and deployment process | ||
RUN docker-php-ext-install mcrypt pdo_mysql zip | ||
|
||
# Install Composer | ||
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
namespace BristolSU\Playground\Support\Authentication; | ||
|
||
use BristolSU\ControlDB\Contracts\Repositories\DataUser; | ||
use BristolSU\Support\User\Contracts\UserRepository; | ||
use BristolSU\Support\User\User; | ||
use Illuminate\Contracts\Auth\Authenticatable; | ||
use Illuminate\Contracts\Hashing\Hasher; | ||
use Illuminate\Database\Eloquent\ModelNotFoundException; | ||
|
||
class UserProvider implements \Illuminate\Contracts\Auth\UserProvider | ||
{ | ||
|
||
/** | ||
* @var UserRepository | ||
*/ | ||
private $userRepository; | ||
|
||
public function __construct(UserRepository $userRepository) | ||
{ | ||
$this->userRepository = $userRepository; | ||
} | ||
|
||
/** | ||
* Retrieve a user by their unique email. | ||
* | ||
* @param mixed $email | ||
* @return User|null | ||
*/ | ||
public function retrieveById($email) | ||
{ | ||
try { | ||
return $this->userRepository->getById($email); | ||
} catch (ModelNotFoundException $e) {} | ||
return null; | ||
} | ||
|
||
/** | ||
* Retrieve a user by their unique email and "remember me" token. | ||
* | ||
* @param mixed $email | ||
* @param string $token | ||
* @return \Illuminate\Contracts\Auth\Authenticatable|null | ||
*/ | ||
public function retrieveByToken($email, $token) | ||
{ | ||
try { | ||
$user = $this->userRepository->getFromRememberToken($token); | ||
if($user->id === $email) { | ||
return $user; | ||
} | ||
} catch (ModelNotFoundException $e) {} | ||
return null; | ||
} | ||
|
||
/** | ||
* Update the "remember me" token for the given user in storage. | ||
* | ||
* @param Authenticatable|User $user | ||
* @param string $token | ||
* @return User|Authenticatable|null | ||
*/ | ||
public function updateRememberToken(Authenticatable $user, $token) | ||
{ | ||
$this->userRepository->setRememberToken($user->id, $token); | ||
} | ||
|
||
/** | ||
* Retrieve a user by the given credentials. | ||
* | ||
* @param array $credentials | ||
* @return \Illuminate\Contracts\Auth\Authenticatable|null | ||
*/ | ||
public function retrieveByCredentials(array $credentials) | ||
{ | ||
|
||
try { | ||
$dataUser = app(DataUser::class)->getWhere([ | ||
'email' => $credentials['email'] | ||
]); | ||
} catch (ModelNotFoundException $e) { | ||
return null; | ||
} | ||
|
||
try { | ||
$controlUser = app(\BristolSU\ControlDB\Contracts\Repositories\User::class)->getByDataProviderId($dataUser->id()); | ||
} catch (ModelNotFoundException $e) { | ||
return null; | ||
} | ||
|
||
try { | ||
$user = $this->userRepository->getFromControlId($controlUser->id()); | ||
} catch (ModelNotFoundException $e) { | ||
return null; | ||
} | ||
|
||
return $user; | ||
} | ||
|
||
/** | ||
* Validate a user against the given credentials. | ||
* | ||
* @param \Illuminate\Contracts\Auth\Authenticatable|User $user | ||
* @param array $credentials | ||
* @return bool | ||
*/ | ||
public function validateCredentials(Authenticatable $user, array $credentials) | ||
{ | ||
if(app(Hasher::class)->check($credentials['password'], $user->password)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: "3.4" | ||
services: | ||
app: | ||
image: php:alpine | ||
volumes: | ||
- "./:/app" | ||
working_dir: /app | ||
command: "php artisan serve --host=0.0.0.0 --port=8000" | ||
ports: | ||
- 8888:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.