Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
esyede committed Jul 25, 2024
1 parent b4d25a1 commit 8e90052
Show file tree
Hide file tree
Showing 60 changed files with 27,874 additions and 24 deletions.
4 changes: 2 additions & 2 deletions application/config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
|
*/

'name' => 'Rakit',
'name' => 'Radmin',

/*
|--------------------------------------------------------------------------
Expand All @@ -24,7 +24,7 @@
|
*/

'url' => '',
'url' => 'https://radmin.test',

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions application/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
|
*/

'default' => 'sqlite',
'default' => 'mysql',

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -58,7 +58,7 @@
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '3306',
'database' => 'database',
'database' => 'radmin',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
Expand Down
18 changes: 18 additions & 0 deletions application/controllers/admin/dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

defined('DS') or exit('No direct access.');

class Admin_Dashboard_Controller extends Controller
{
public $restful = true;

public function __construct()
{
$this->middleware('before', 'csrf|throttle:60,1|admin');
}

public function get_index()
{
return View::make('admin.dashboard');
}
}
1 change: 1 addition & 0 deletions application/controllers/admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No direct access.
49 changes: 49 additions & 0 deletions application/controllers/auth/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

defined('DS') or exit('No direct access.');

class Auth_Login_Controller extends Controller
{
public $restful = true;

public function __construct()
{
$this->middleware('before', 'csrf|throttle:60,1');
}

public function get_login()
{
return View::make('auth.login');
}

public function post_login()
{
$validation = Validator::make(Input::all(), [
'email' => 'required|email',
'password' => 'required',
]);

if ($validation->fails()) {
return Redirect::back()
->with_input()
->with_errors($validation);
}

$credentials = Input::only('email', 'password');
$remember = Input::has('remember');

if (!Auth::attempt($credentials, $remember)) {
return Redirect::back()
->with_input()
->with('error', 'Invalid credentials.');
}

return Redirect::to(Auth::user()->role === 'admin' ? 'admin' : 'member');
}

public function post_logout()
{
Auth::logout();
return Redirect::to('/');
}
}
111 changes: 111 additions & 0 deletions application/controllers/auth/password.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

defined('DS') or exit('No direct access.');

class Auth_Password_Controller extends Controller
{
public $restful = true;

public function __construct()
{
$this->middleware('before', 'csrf|throttle:60,1');
}

public function get_resend()
{
return View::make('auth.passwords.email');
}

public function post_resend()
{
$validation = Validator::make(Input::all(), [
'email' => 'required|email|exists:users|max:191',
]);

if ($validation->fails()) {
return Redirect::back()
->with_input()
->with_errors($validation);
}

$token = Str::random();

DB::table('password_resets')->insert([
'email' => Input::get('email'),
'token' => $token,
'created_at' => now(),
]);

$html = View::make('auth.email.reset', compact('token'))->render();
Email::from(config('email.from.email'))
->to(Input::get('email'))
->subject('Reset Password')
->html_body($html)
->priority(Email::HIGH)
->send();

return Redirect::back()
->with('status', 'A password reset link has been sent to your email address.');
}

public function get_reset()
{
$token = URI::segment(3);

if (!$token) {
return Response::error(404);
}

$reset = DB::table('password_resets')
->where('token', $token)
->first();

if (!$reset) {
return Response::error(404);
}

return View::make('auth.passwords.reset')
->with('token', $reset->token);
}

public function post_reset()
{
$validation = Validator::make(Input::all(), [
'token' => 'required',
'email' => 'required|email|max:191',
'password' => 'required|confirmed|min:8|max:191',
]);

if ($validation->fails()) {
return Redirect::back()
->with_input()
->with_errors($validation)
->with('token', Input::get('token'));
}

$reset = DB::table('password_resets')
->where('token', Input::get('token'))
->first();

abort_if(!$reset, 404);

$user = DB::table('users')->where('email', Input::get('email'))->first();

abort_if(!$user, 404);

DB::table('users')->where('id', $user->id)->update([
'password' => Hash::make(Input::get('password')),
'updated_at' => now(),
]);

DB::table('password_resets')->delete($reset->id);

Auth::login($user->id);

return Redirect::to('/dashboard')
->with('status', sprintf(
'Your password has been successfuly reset to: %s',
Input::get('password')
));
}
}
45 changes: 45 additions & 0 deletions application/controllers/auth/register.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

defined('DS') or exit('No direct access.');

class Auth_Register_Controller extends Controller
{
public $restful = true;

public function __construct()
{
$this->middleware('before', 'csrf|throttle:60,1');
}

public function get_register()
{
return View::make('auth.register');
}

public function post_register()
{
$validation = Validator::make(Input::all(), [
'name' => 'required|min:3|max:191',
'email' => 'required|email|max:191|unique:users',
'phone' => 'required|min:10|max:15|unique:users',
'password' => 'required|confirmed|min:8|max:191',
]);

if ($validation->fails()) {
return Redirect::back()
->with_input()
->with_errors($validation);
}

$user_id = DB::table('users')->insert_get_id([
'name' => Input::get('name'),
'email' => Input::get('email'),
'phone' => Input::get('phone'),
'password' => Hash::make(Input::get('password')),
'created_at' => now(),
]);

Auth::login($user_id);
return Redirect::to('/dashboard');
}
}
12 changes: 3 additions & 9 deletions application/controllers/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@

class Home_Controller extends Controller
{
/**
* Buat instance controller baru.
*/
public $restful = true;

public function __construct()
{
$this->middleware('before', 'csrf|throttle:60,1');
}

/**
* Handle GET /.
*
* @return View
*/
public function action_index()
public function get_index()
{
return View::make('home');
}
Expand Down
18 changes: 18 additions & 0 deletions application/controllers/member/dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

defined('DS') or exit('No direct access.');

class Member_Dashboard_Controller extends Controller
{
public $restful = true;

public function __construct()
{
$this->middleware('before', 'csrf|throttle:60,1|auth');
}

public function get_index()
{
return View::make('member.dashboard');
}
}
1 change: 1 addition & 0 deletions application/controllers/member/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No direct access.
Loading

0 comments on commit 8e90052

Please sign in to comment.