Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions app/Http/Controllers/Auth/VerificationController.php

This file was deleted.

10 changes: 7 additions & 3 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getIndex() {
public function getLink(Request $request) {
// If the user already has an alias associated with their account, redirect them
if (Auth::check() && Auth::user()->hasAlias) {
redirect()->to('home');
return redirect()->route('home');
}

// Display the login link
Expand Down Expand Up @@ -111,7 +111,11 @@ public function getAuthCallback(LinkService $service, $provider) {
public function getEmail(Request $request) {
// If the user already has an email associated with their account, redirect them
if (Auth::check() && Auth::user()->hasEmail) {
return redirect()->to('home');
return redirect()->route('home');
}

if (config('lorekeeper.settings.allow_unverified_users_to_modify_emails') && $request->is('email/update')) {
return view('auth.update_email');
}

// Step 1: display a login email
Expand All @@ -128,7 +132,7 @@ public function postEmail(UserService $service, Request $request) {
if ($service->updateEmail(['email' => $data], Auth::user())) {
flash('Email added successfully!');

return redirect()->to('home');
return redirect()->route('home');
} else {
foreach ($service->errors()->getMessages()['error'] as $error) {
flash($error)->error();
Expand Down
11 changes: 10 additions & 1 deletion app/Models/Rank/Rank.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getDisplayNameAttribute() {
* @return bool
*/
public function getIsAdminAttribute() {
return $this->attributes['is_admin'];
return $this->attributes['is_admin'] || $this->powers()->where('power', 'admin')->exists();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See, I understand why you've done this. But you've put back the query that's going to be everywhere...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you prefer another attribute?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure what the ideal solution is (brainfog's been bad lately), beyond wanting to avoid a query if possible for performance reasons.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a bit redundant and roundabout, but why not add a column 'fauxAdmin' with a bool.. that way you only need to pull that attribute..?

Does mean you'd have to slightly rewrite the rank controller, so that it actually gets set or unset depending on whether the power is there..

Copy link
Copy Markdown

@perappu perappu Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually thinking on this morning and I agree that's probably the best approach, even if it's technically data duplication. Alternatively, would always eager loading powers alongside Rank solve the issue? aka setting the $with on the Rank model. To some degree I'm surprised it doesn't do that already

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly? re the latter

}

/**********************************************************************************************
Expand All @@ -95,6 +95,15 @@ public function canEditRank($rank) {
}
if ($this->hasPower('edit_ranks')) {
if ($this->isAdmin) {
// editing a false admin rank
if ($rank->powers()->where('power', 'admin')->exists()) {
if ($this->attributes['is_admin']) {
return 3; // must remove admin power to edit more granularly
} else {
return 4; // false admin rank, cannot edit
}
}

if ($rank->id != $this->id) {
return 1;
} // can edit everything
Expand Down
5 changes: 4 additions & 1 deletion config/lorekeeper/powers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
| The list of staff powers that can be attached to a user rank.
|
*/

'admin' => [
'name' => 'Administrator Access',
'description' => 'Grants all powers automatically. Grant this power wisely.',
],
'edit_site_settings' => [
'name' => 'Edit Site Settings',
'description' => 'Allow rank to modify site settings and upload new images to replace the site layout images.',
Expand Down
10 changes: 10 additions & 0 deletions config/lorekeeper/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,14 @@
|
*/
'enable_character_content_warnings' => 1,

/*
|--------------------------------------------------------------------------
| Allow Unverified Users to Modify their Email Addresses
|--------------------------------------------------------------------------
|
| Allows users who have not yet verified their email addresses
| to modify their email address, in order to correct mistakes.
*/
'allow_unverified_users_to_modify_emails' => 1,
];
36 changes: 29 additions & 7 deletions resources/views/admin/users/_create_edit_rank.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,44 @@
</div>
</div>

@if ($editable != 2)
{{-- Powers --}}
<div class="form-group">
<div class="row">
@if ($editable == 2)
<div class="card bg-light mb-3">
<div class="card-body">Powers for the admin rank cannot be edited. {!! add_help('The admin rank has the ability to edit any editable information on the site, and is always highest-ranked (cannot be edited by any other user).') !!}</div>
</div>
@elseif ($editable == 3)
<div class="card bg-light mb-3">
<div class="card-body">
This rank has the "Admin" power granted to it, meaning it has all powers. If you want to edit this rank, you must remove the "Admin" power first.
@foreach ($powers as $key => $power)
<div class="col-md-6 form-check">
@if ($key != 'admin')
@continue
@endif
<div class="col-md-6 form-group ml-1 mt-2 mb-0">
{!! Form::checkbox('powers[' . $key . ']', $key, $rankPowers ? isset($rankPowers[$key]) : false, ['class' => 'form-check-input', 'id' => 'powers[' . $key . ']']) !!}
{!! Form::label('powers[' . $key . ']', $power['name'], ['class' => 'form-check-label']) !!}
{!! add_help($power['description']) !!}
</div>
@endforeach
</div>
</div>
@else
@elseif ($editable == 4)
<div class="card bg-light mb-3">
<div class="card-body">Powers for the admin rank cannot be edited. {!! add_help('The admin rank has the ability to edit any editable information on the site, and is always highest-ranked (cannot be edited by any other user).') !!}</div>
<div class="card-body">
You cannot edit this rank.
</div>
</div>
@else
{{-- Powers --}}
<div class="row">
@foreach ($powers as $key => $power)
<div class="col-md-6">
<div class="form-check">
{!! Form::checkbox('powers[' . $key . ']', $key, $rankPowers ? isset($rankPowers[$key]) : false, ['class' => 'form-check-input', 'id' => 'powers[' . $key . ']']) !!}
{!! Form::label('powers[' . $key . ']', $power['name'], ['class' => 'form-check-label']) !!}
{!! add_help($power['description']) !!}
</div>
</div>
@endforeach
</div>
@endif

Expand Down
41 changes: 41 additions & 0 deletions resources/views/auth/update_email.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@extends('layouts.app')

@section('title')
Update Email Address
@endsection

@section('content')
<h1>Update Email Address</h1>
<p class="mb-1">
The currently linked email to your account is:
</p>
<div class="alert alert-secondary mb-2" role="alert">
{{ Auth::user()->email }}
</div>
<p>
If this email address is incorrect, please enter the correct email address below to update it.
</p>


{!! Form::open(['url' => 'email/update', 'method' => 'POST']) !!}

<div class="form-group row">
{!! Form::label('email', 'Email Address', ['class' => 'col-md-4 col-form-label text-md-right']) !!}
<div class="col-md-6">
{!! Form::email('email', old('email'), ['class' => 'form-control' . ($errors->has('email') ? ' is-invalid' : ''), 'required']) !!}
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>

<div class="form-group row">
<div class="col-md-6 offset-md-4">
{!! Form::submit('Update Email Address', ['class' => 'btn btn-primary']) !!}
</div>
</div>

{!! Form::close() !!}
@endsection
7 changes: 7 additions & 0 deletions resources/views/auth/verify.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@
{{ __('click here to request another') }}
</button>.
</form>

@if (config('lorekeeper.settings.allow_unverified_users_to_modify_emails'))
<div class="alert alert-warning mt-3" role="alert">
{{ __('If you need to change your email address, you can do so') }}
<a href="{{ url('email/update') }}">{{ __('here') }}</a>.
</div>
@endif
@endsection
7 changes: 7 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

Route::feeds('feeds');

// Updating email from verification notice
Route::middleware('auth')->group(function () {
Route::get('/email/update', 'HomeController@getEmail');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 100% a nitpick- wondering why there's an empty line in between is all :)

Route::post('/email/update', 'HomeController@postEmail');
});

/**************************************************************************************************
Routes that require login
**************************************************************************************************/
Expand Down