Feature flags (#543)
* Re-organize a bit controllers * Added the featureflagcontroller * Implement feature flags in the front-end * Clean env files * Clean console.log messages * Fix feature flag test
This commit is contained in:
61
api/app/Http/Controllers/Auth/UserInviteController.php
Normal file
61
api/app/Http/Controllers/Auth/UserInviteController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Models\UserInvite;
|
||||
use App\Models\Workspace;
|
||||
use App\Service\WorkspaceHelper;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class UserInviteController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function listInvites(Request $request, $workspaceId)
|
||||
{
|
||||
$workspace = Workspace::findOrFail($workspaceId);
|
||||
$this->authorize('view', $workspace);
|
||||
|
||||
return (new WorkspaceHelper($workspace))->getAllInvites();
|
||||
}
|
||||
|
||||
public function resendInvite($workspaceId, $inviteId)
|
||||
{
|
||||
$workspace = Workspace::findOrFail($workspaceId);
|
||||
$this->authorize('adminAction', $workspace);
|
||||
$userInvite = $workspace->invites()->find($inviteId);
|
||||
if (!$userInvite) {
|
||||
return $this->error(['success' => false, 'message' => 'Invite not found for this workspace.']);
|
||||
}
|
||||
|
||||
if ($userInvite->status == UserInvite::ACCEPTED_STATUS) {
|
||||
return $this->error(['success' => false, 'message' => 'Invite already accepted.']);
|
||||
}
|
||||
|
||||
$userInvite->sendEmail();
|
||||
|
||||
return $this->success(['message' => 'Invite email resent successfully.']);
|
||||
}
|
||||
|
||||
public function cancelInvite($workspaceId, $inviteId)
|
||||
{
|
||||
$workspace = Workspace::findOrFail($workspaceId);
|
||||
$this->authorize('adminAction', $workspace);
|
||||
$userInvite = $workspace->invites()->find($inviteId);
|
||||
if (!$userInvite) {
|
||||
return $this->error(['success' => false, 'message' => 'Invite not found for this workspace.']);
|
||||
}
|
||||
|
||||
if ($userInvite->status == UserInvite::ACCEPTED_STATUS) {
|
||||
return $this->error(['success' => false, 'message' => 'Invite already accepted.']);
|
||||
}
|
||||
|
||||
$userInvite->delete();
|
||||
|
||||
return $this->success(['message' => 'Invite deleted successfully.']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user