Skip to content

Commit

Permalink
Merge pull request #34 from codeHack-s/LastCodehack
Browse files Browse the repository at this point in the history
Last codehack
  • Loading branch information
Raccoon254 authored Jan 11, 2024
2 parents 36c1488 + fb31c5e commit 7c1891b
Show file tree
Hide file tree
Showing 174 changed files with 2,185 additions and 11,084 deletions.
Binary file removed .env.swp
Binary file not shown.
17 changes: 0 additions & 17 deletions app/Http/Controllers/AdminController.php

This file was deleted.

2 changes: 0 additions & 2 deletions app/Http/Controllers/Auth/AuthenticatedSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public function store(LoginRequest $request): RedirectResponse

$request->session()->regenerate();

Auth::user()->update(['last_login_at' => now()]);

return redirect()->intended(RouteServiceProvider::HOME);
}

Expand Down
92 changes: 9 additions & 83 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,115 +11,41 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;

class RegisteredUserController extends Controller
{
/**
* Display the registration view.
*/
public function create(Request $request, $type = null): View
public function create(): View
{
if ($type === 'campus') {
return view('auth.register');
} elseif ($type === 'innovate') {
return view('auth.innovate.register');
} else {
return view('auth.select-account-type');
}
return view('auth.register');
}

/**
* Handle an incoming registration request.
*
* @throws ValidationException
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request): RedirectResponse
{
$this->storeValidation($request);

$user = User::create([
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'username' => $request->username,
'email' => $request->email,
'password' => Hash::make($request->password),
'phone_number' => $request->phone_number,
'user_type' => 'campus',
$request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);

event(new Registered($user));

Auth::login($user);
Auth::user()->update(['last_login_at' => now()]);

// Send verification email
if(!$user->hasVerifiedEmail()) {
$user->sendEmailVerificationNotification();
}

return redirect()->route('verification.notice');
}

public function store_innovate(Request $request): RedirectResponse
{
$this->storeValidation($request);

$user = User::create([
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'username' => $request->username,
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
'phone_number' => $request->phone_number,
'user_type' => 'innovate',
]);

event(new Registered($user));

Auth::login($user);
Auth::user()->update(['last_login_at' => now()]);

// Send verification email
if(!$user->hasVerifiedEmail()) {
$user->sendEmailVerificationNotification();
}

return redirect()->route('verification.notice');
return redirect(RouteServiceProvider::HOME);
}

/**
* @param Request $request
* @return void
*/
public function storeValidation(Request $request): void
{
$request->validate([
'first_name' => ['required', 'string', 'max:255'],
'last_name' => ['required', 'string', 'max:255'],
'username' => ['required', 'string', 'max:255', 'unique:' . User::class],
'email' => ['required', 'string', 'email', 'max:255', 'unique:' . User::class],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
'phone_number' => ['nullable', 'string', 'max:255'],
]);

$contact = $request->contact;

//remove the first character if it's a '+'
if (str_starts_with($contact, '+')) {
$contact = substr($contact, 1);
}

//dd($contact);

// Check if the first character of the string is '0'
if (str_starts_with($contact, '0')) {
// Replace the first character '0' with '254'
$contact = '254' . substr($contact, 1);
}

$request->merge(['contact' => $contact]);
}

}
15 changes: 0 additions & 15 deletions app/Http/Controllers/ConnectController.php

This file was deleted.

210 changes: 0 additions & 210 deletions app/Http/Controllers/CourseController.php

This file was deleted.

Loading

0 comments on commit 7c1891b

Please sign in to comment.