Browse Source

added new Views Account/Edit & Account/Home

- updated languages (added new line)
- added Controller Account/Edit
- updated existing Account Controllers
- updated Templates/Header View
- updated Libraries/Aauth
v3-dev
REJack 7 years ago
parent
commit
cf00edaf60
No known key found for this signature in database
GPG Key ID: 4A44B48700429F46
  1. 88
      application/Controllers/Account/Edit.php
  2. 16
      application/Controllers/Account/Home.php
  3. 6
      application/Controllers/Account/Logout.php
  4. 1
      application/Controllers/Account/Register.php
  5. 3
      application/Controllers/Account/Remind_password.php
  6. 3
      application/Controllers/Account/Reset_password.php
  7. 2
      application/Controllers/Account/Verification.php
  8. 1
      application/Language/de/Aauth.php
  9. 1
      application/Language/en/Aauth.php
  10. 10
      application/Language/en/Account.php
  11. 1
      application/Language/es/Aauth.php
  12. 1
      application/Language/fa/Aauth.php
  13. 1
      application/Language/fr/Aauth.php
  14. 1
      application/Language/id/Aauth.php
  15. 1
      application/Language/ru/Aauth.php
  16. 1
      application/Language/sv/Aauth.php
  17. 1
      application/Language/zh-CN/Aauth.php
  18. 1
      application/Language/zh-TW/Aauth.php
  19. 6
      application/Libraries/Aauth.php
  20. 32
      application/Views/Account/Edit.php
  21. 3
      application/Views/Account/Home.php
  22. 6
      application/Views/Templates/Header.php

88
application/Controllers/Account/Edit.php

@ -0,0 +1,88 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like groupping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Magefly Team
* @copyright 2014-2017 Emre Akay
* @copyright 2018 Magefly
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/magefly/CodeIgniter-Aauth
*/
namespace App\Controllers\Account;
use CodeIgniter\Controller;
use Config\Aauth as AauthConfig;
use App\Libraries\Aauth;
use Config\Services;
/**
* Aauth Accont/Edit Controller
*
* @package CodeIgniter-Aauth
*/
class Edit extends Controller
{
/**
* Constructor
*/
public function __construct()
{
$this->config = new AauthConfig();
$this->aauth = new Aauth();
$this->request = Services::request();
helper('form');
helper('aauth');
}
/**
* Index
*
* @return void
*/
public function index()
{
$userId = $this->aauth->getUserId();
if ($input = $this->request->getPost())
{
$email = $password = $username = null;
if (! empty($input['email']))
{
$email = $input['email'];
}
if (! empty($input['password']))
{
$password = $input['password'];
}
if (! empty($input['username']))
{
$username = $input['username'];
}
if (! $this->aauth->updateUser($userId, $email, $password, $username))
{
$data['errors'] = $this->aauth->printErrors('<br />', true);
}
else
{
$data['infos'] = $this->aauth->printInfos('<br />', true);
}
}
$data['useUsername'] = $this->config->loginUseUsername;
echo view('Templates/Header', $data);
echo view('Account/Edit', $data);
echo view('Templates/Footer', $data);
}
}

16
application/Controllers/Account/Home.php

@ -18,7 +18,6 @@
namespace App\Controllers\Account;
use CodeIgniter\Controller;
use Config\Aauth as AauthConfig;
use App\Libraries\Aauth;
use App\Models\Aauth\UserModel;
@ -34,9 +33,8 @@ class Home extends Controller
*/
public function __construct()
{
$this->config = new AauthConfig();
$this->user = new UserModel();
$this->aauth = new Aauth();
$this->aauth = new Aauth();
helper('aauth');
if (! $this->aauth->isLoggedIn())
{
@ -51,12 +49,10 @@ class Home extends Controller
*/
public function index()
{
// print_r($this->aauth->session);
// print_r($this->aauth->login("admin@example.com", "password123456"));
// print_r($this->aauth->deleteUser(4));
// print_r($this->aauth->updateUser(1, "admin@example.com", "password", 'Admines'));
// print_r($this->aauth->createUser("admin@example.coma", 'asdasasdasdsd'));
$data['user'] = $this->aauth->getUser();
echo $this->aauth->printErrors('<br />', true);
echo view('Templates/Header');
echo view('Account/Home', $data);
echo view('Templates/Footer');
}
}

6
application/Controllers/Account/Logout.php

@ -18,9 +18,7 @@
namespace App\Controllers\Account;
use CodeIgniter\Controller;
use Config\Aauth as AauthConfig;
use App\Libraries\Aauth;
use Config\Services;
/**
* Aauth Accont/Logout Controller
@ -34,9 +32,7 @@ class Logout extends Controller
*/
public function __construct()
{
$this->config = new AauthConfig();
$this->aauth = new Aauth();
$this->request = Services::request();
$this->aauth = new Aauth();
helper('form');
}

1
application/Controllers/Account/Register.php

@ -20,7 +20,6 @@ namespace App\Controllers\Account;
use CodeIgniter\Controller;
use Config\Aauth as AauthConfig;
use App\Libraries\Aauth;
use App\Models\Aauth\UserVariableModel as UserVariableModel;
use Config\Services;
/**

3
application/Controllers/Account/Remind_password.php

@ -18,9 +18,7 @@
namespace App\Controllers\Account;
use CodeIgniter\Controller;
use Config\Aauth as AauthConfig;
use App\Libraries\Aauth;
use App\Models\Aauth\UserVariableModel as UserVariableModel;
use Config\Services;
/**
@ -35,7 +33,6 @@ class Remind_password extends Controller
*/
public function __construct()
{
$this->config = new AauthConfig();
$this->aauth = new Aauth();
$this->request = Services::request();
helper('form');

3
application/Controllers/Account/Reset_password.php

@ -18,9 +18,7 @@
namespace App\Controllers\Account;
use CodeIgniter\Controller;
use Config\Aauth as AauthConfig;
use App\Libraries\Aauth;
use App\Models\Aauth\UserVariableModel as UserVariableModel;
use Config\Services;
/**
@ -35,7 +33,6 @@ class Reset_password extends Controller
*/
public function __construct()
{
$this->config = new AauthConfig();
$this->aauth = new Aauth();
$this->request = Services::request();
helper('form');

2
application/Controllers/Account/Verification.php

@ -18,7 +18,6 @@
namespace App\Controllers\Account;
use CodeIgniter\Controller;
use Config\Aauth as AauthConfig;
use App\Libraries\Aauth;
use Config\Services;
@ -34,7 +33,6 @@ class Verification extends Controller
*/
public function __construct()
{
$this->config = new AauthConfig();
$this->aauth = new Aauth();
$this->request = Services::request();
helper('form');

1
application/Language/de/Aauth.php

@ -35,6 +35,7 @@ return [
'infoCreateSuccess' => 'Dein Benutzerkonto wurde erfolgreich erstellt, du kannst dich jetzt einloggen.',
'infoCreateVerification' => 'Dein Benutzerkonto wurde erfolgreich erstellt. Eine E-Mail mit Informationen zur Bestätigung wurde an deine E-Mail-Adresse versendet. ',
'infoUpdateSuccess' => 'Dein Benutzerkonto wurde erfolgreich geändert.',
'infoRemindSuccess' => 'Eine E-Mail mit Informationen zum zurückzusetzen wurde an deine E-Mail-Adresse versendet.',
'infoResetSuccess' => 'Eine E-Mail mit deinem neuem Passwort wurde an deine E-Mail-Adresse versendet.',
'infoVerification' => 'Dein Benutzerkonto wurde erfolgreich bestätigt, du kannst dich jetzt einloggen.',

1
application/Language/en/Aauth.php

@ -35,6 +35,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

10
application/Language/en/Account.php

@ -25,6 +25,16 @@
* @codeCoverageIgnore
*/
return [
'homeText' => 'Account Details',
'homeLabelUsername' => 'Username',
'homeLabelEmail' => 'Email address',
'editHeader' => 'Edit Profile',
'editLabelUsername' => 'Username',
'editLabelEmail' => 'Email address',
'editLabelPassword' => 'Password',
'editLabelSubmit' => 'Save changes',
'linkBackToLogin' => 'Back to Login',
'linkLogin' => 'Login',
'linkRegister' => 'Register new Account',

1
application/Language/es/Aauth.php

@ -35,6 +35,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

1
application/Language/fa/Aauth.php

@ -35,6 +35,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

1
application/Language/fr/Aauth.php

@ -35,6 +35,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

1
application/Language/id/Aauth.php

@ -35,6 +35,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

1
application/Language/ru/Aauth.php

@ -35,6 +35,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

1
application/Language/sv/Aauth.php

@ -35,6 +35,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

1
application/Language/zh-CN/Aauth.php

@ -37,6 +37,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

1
application/Language/zh-TW/Aauth.php

@ -37,6 +37,7 @@ return [
'infoCreateSuccess' => 'Your account has successfully been created. You can now login.',
'infoCreateVerification' => 'Your account has successfully been created. A email has been sent to your email address with verification details..',
'infoUpdateSuccess' => 'Your account has successfully updated.',
'infoRemindSuccess' => 'A email has been sent to your email address with reset instructions.',
'infoResetSuccess' => 'A email has been sent to your email address with your new password has been sent.',
'infoVerification' => 'Your account has been verified successfully, you can now login.',

6
application/Libraries/Aauth.php

@ -169,7 +169,7 @@ class Aauth
return false;
}
else if (! is_null($email) && ! is_null($password) && ! is_null($username))
else if (is_null($email) && is_null($password) && is_null($username))
{
return false;
}
@ -193,6 +193,8 @@ class Aauth
if ($userModel->update($userId, $data))
{
$this->info(lang('Aauth.infoUpdateSuccess'));
return true;
}
@ -378,7 +380,7 @@ class Aauth
if ($user = $userModel->where($where)->first())
{
return $user->id;
return $user['id'];
}
return false;

32
application/Views/Account/Edit.php

@ -0,0 +1,32 @@
<div class="card">
<div class="card-header"><?=lang('Account.editHeader')?></div>
<div class="card-body">
<form method="POST">
<?if (isset($errors)):?>
<div class="alert alert-danger"><?=$errors?></div>
<?endif;?>
<?if (isset($infos)):?>
<div class="alert alert-success"><?=$infos?></div>
<?endif;?>
<div class="form-group">
<div class="form-label-group">
<input type="email" name="email" id="inputEmail" class="form-control" placeholder="<?=lang('Account.editLabelEmail')?>" autofocus>
<label for="inputEmail"><?=lang('Account.editLabelEmail')?></label>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="text" name="username" id="inputUsername" class="form-control" placeholder="<?=lang('Account.editLabelUsername')?>">
<label for="inputUsername"><?=lang('Account.editLabelUsername')?></label>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="<?=lang('Account.editLabelPassword')?>">
<label for="inputPassword"><?=lang('Account.editLabelPassword')?></label>
</div>
</div>
<button class="btn btn-primary btn-block" type="submit"><?=lang('Account.editLabelSubmit')?></button>
</form>
</div>
</div>

3
application/Views/Account/Home.php

@ -0,0 +1,3 @@
<h2><?= lang('Account.homeText') ?></h2> <br />
<?= lang('Account.homeLabelUsername') ?>: <?= $user['username'] ?> <br />
<?= lang('Account.homeLabelEmail') ?>: <?= $user['email'] ?> <br />

6
application/Views/Templates/Header.php

@ -18,7 +18,7 @@
</head>
<body id="page-top">
<nav class="navbar navbar-expand navbar-dark bg-dark static-top">
<a class="navbar-brand mr-1" href="index.html">Aauth</a>
<a class="navbar-brand mr-1" href="<?= site_url() ?>">Aauth</a>
<ul class="navbar-nav ml-4">
<li class="nav-item">
<a href="<?= site_url() ?>">Home</a>
@ -31,8 +31,8 @@
<i class="fas fa-user-circle fa-fw"></i>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown">
<!-- <a class="dropdown-item" href="#">Settings</a> -->
<!-- <div class="dropdown-divider"></div> -->
<a class="dropdown-item" href="<?= site_url('account/edit') ?>">Edit Profile</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?= site_url('account/logout') ?>">Logout</a>
</div>
</li>

Loading…
Cancel
Save