1
0
mirror of https://koodu.h-i.works/projects/thebadspace synced 2025-06-25 16:04:37 -05:00

admin account set up

after the site is installed and the DB set up, there needed to be a way
to create the first account that will be used as the admin to access the
den, the admin section of tbs

the system makes a check to see if this account exists and if there
isn't one present, it shows the admin account set up screen on the
index. it goes away after the account is created.
This commit is contained in:
ro
2025-04-17 17:14:15 -06:00
parent 515de4c56b
commit 56f445572f
6 changed files with 194 additions and 111 deletions

View File

@ -151,4 +151,32 @@ class MemberController extends Controller
return back()->withErrors(['Nah, you can\'t do this. Wrong permissions.']);
}
}
public function adminCreate(Request $request)
{
//should only be run of no members exist
if (count($this->member->getAll()) == 0) {
$token = csrf_token();
$valid = $request->validate([
'handle' => ['required'],
'email' => ['required'],
'pronouns' => ['required'],
'fresh_pass' => ['required'],
'fresh_pass_confirm' => ['required'],
]);
if ($valid) {
$response = $this->member->add($request);
if ($response['status'] == true) {
return redirect('/den/member')->with('message', $response['message']);
} else {
return back()->withErrors([$response['message']]);
}
} else {
return back()->withErrors(['Misssing some required info, homie.']);
}
} else {
return back()->withErrors(['Shame on you for even trying that.']);
}
}
}