mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
encrypt user data
This commit is contained in:
@@ -13,10 +13,15 @@ use Laravel\Sanctum\HasApiTokens;
|
||||
use QCod\Gamify\Gamify;
|
||||
use Spatie\Comments\Models\Concerns\InteractsWithComments;
|
||||
use Spatie\Comments\Models\Concerns\Interfaces\CanComment;
|
||||
use Spatie\LaravelCipherSweet\Concerns\UsesCipherSweet;
|
||||
use Spatie\LaravelCipherSweet\Contracts\CipherSweetEncrypted;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use ParagonIE\CipherSweet\EncryptedRow;
|
||||
use ParagonIE\CipherSweet\BlindIndex;
|
||||
|
||||
class User extends Authenticatable implements MustVerifyEmail, CanComment
|
||||
class User extends Authenticatable implements MustVerifyEmail, CanComment, CipherSweetEncrypted
|
||||
{
|
||||
use UsesCipherSweet;
|
||||
use HasApiTokens;
|
||||
use HasFactory;
|
||||
use HasProfilePhoto;
|
||||
@@ -56,6 +61,21 @@ class User extends Authenticatable implements MustVerifyEmail, CanComment
|
||||
'profile_photo_url',
|
||||
];
|
||||
|
||||
public static function configureCipherSweet(EncryptedRow $encryptedRow): void
|
||||
{
|
||||
$encryptedRow
|
||||
->addField('public_key')
|
||||
->addField('lightning_address')
|
||||
->addField('lnurl')
|
||||
->addField('node_id')
|
||||
->addField('email')
|
||||
->addBlindIndex('public_key', new BlindIndex('public_key_index'))
|
||||
->addBlindIndex('lightning_address', new BlindIndex('lightning_address_index'))
|
||||
->addBlindIndex('lnurl', new BlindIndex('lnurl_index'))
|
||||
->addBlindIndex('node_id', new BlindIndex('node_id_index'))
|
||||
->addBlindIndex('email', new BlindIndex('email_index'));
|
||||
}
|
||||
|
||||
public function orangePills()
|
||||
{
|
||||
return $this->hasMany(OrangePill::class);
|
||||
|
||||
@@ -30,7 +30,7 @@ class User extends Resource
|
||||
* @var array
|
||||
*/
|
||||
public static $search = [
|
||||
'id', 'name', 'email',
|
||||
'id', 'name',
|
||||
];
|
||||
|
||||
public static function label()
|
||||
|
||||
@@ -9,14 +9,17 @@ use App\Actions\Jetstream\DeleteUser;
|
||||
use App\Actions\Jetstream\InviteTeamMember;
|
||||
use App\Actions\Jetstream\RemoveTeamMember;
|
||||
use App\Actions\Jetstream\UpdateTeamName;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\Fortify\Fortify;
|
||||
use Laravel\Jetstream\Jetstream;
|
||||
|
||||
class JetstreamServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
@@ -26,7 +29,6 @@ class JetstreamServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
@@ -40,11 +42,22 @@ class JetstreamServiceProvider extends ServiceProvider
|
||||
Jetstream::removeTeamMembersUsing(RemoveTeamMember::class);
|
||||
Jetstream::deleteTeamsUsing(DeleteTeam::class);
|
||||
Jetstream::deleteUsersUsing(DeleteUser::class);
|
||||
|
||||
Fortify::authenticateUsing(function (Request $request) {
|
||||
$user = User::query()
|
||||
->whereBlind('email', 'email_index', $request->email)
|
||||
->first();
|
||||
|
||||
if ($user &&
|
||||
Hash::check($request->password, $user->password)) {
|
||||
|
||||
return $user;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the roles and permissions that are available within the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configurePermissions()
|
||||
@@ -56,12 +69,14 @@ class JetstreamServiceProvider extends ServiceProvider
|
||||
'read',
|
||||
'update',
|
||||
'delete',
|
||||
])->description('Administrator users can perform any action.');
|
||||
])
|
||||
->description('Administrator users can perform any action.');
|
||||
|
||||
Jetstream::role('editor', 'Editor', [
|
||||
'read',
|
||||
'create',
|
||||
'update',
|
||||
])->description('Editor users have the ability to read, create, and update.');
|
||||
])
|
||||
->description('Editor users have the ability to read, create, and update.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user