diff --git a/app/Entities/Users/UserPresenter.php b/app/Entities/Users/UserPresenter.php index c980cf4..2ca756d 100644 --- a/app/Entities/Users/UserPresenter.php +++ b/app/Entities/Users/UserPresenter.php @@ -40,23 +40,4 @@ class UserPresenter extends Presenter return $string; } - - public function displayPermissions() - { - $string = '
'; - - return $string; - } - - public function photo() - { - return Html::image('assets/imgs/icon_user_1.png', $this->name, ['width' => '100px']); - } - } \ No newline at end of file diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 5a450ee..70251a9 100755 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -6,22 +6,19 @@ use App\Entities\Users\User; use App\Http\Requests\Accounts\ChangePasswordRequest; use App\Http\Requests\Accounts\LoginRequest; use App\Http\Requests\Accounts\RegisterRequest; -use App\Http\Requests\Accounts\UpdateProfileRequest; use Auth; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\PasswordBroker; use Illuminate\Foundation\Auth\ResetsPasswords; use Illuminate\Foundation\Auth\ThrottlesLogins; +use Illuminate\Http\Request; class AuthController extends Controller { use ResetsPasswords, ThrottlesLogins; - private $user; - public function __construct(Guard $auth, PasswordBroker $passwords) { - $this->user = Auth::user(); $this->auth = $auth; $this->passwords = $passwords; @@ -42,11 +39,14 @@ class AuthController extends Controller return view('auth.login'); } - public function postLogin(LoginRequest $request) + public function postLogin(Request $request) { - $loginData = $request->only('email', 'password'); + $loginData = $request->validate([ + 'email' => 'required|email', + 'password' => 'required', + ]); - if (Auth::attempt($loginData, $request->has('remember'))) { + if (Auth::attempt($loginData)) { flash()->success(trans('auth.welcome', ['name' => Auth::user()->name])); return redirect()->intended('home'); } @@ -92,9 +92,11 @@ class AuthController extends Controller { $input = $request->except('_token'); - if (app('hash')->check($input['old_password'], $this->user->password)) { - $this->user->password = $input['password']; - $this->user->save(); + $user = auth()->user(); + + if (app('hash')->check($input['old_password'], $user->password)) { + $user->password = $input['password']; + $user->save(); flash()->success(trans('auth.password_changed')); return redirect()->back(); @@ -110,12 +112,20 @@ class AuthController extends Controller return view('auth.profile', compact('user')); } - public function patchProfile(UpdateProfileRequest $request) + public function patchProfile(Request $request) { - $this->user->name = $request->get('name'); - $this->user->save(); + $profileData = $request->validate([ + 'name' => 'required|max:60', + 'email' => 'required|email', + ]); + + $user = auth()->user(); + + $user->name = $profileData['name']; + $user->email = $profileData['email']; + $user->save(); - flash()->success('Profil berhasil diupdate.'); - return redirect()->route('auth.profile'); + flash()->success(trans('auth.profile_updated')); + return back(); } } diff --git a/app/Http/Requests/Accounts/LoginRequest.php b/app/Http/Requests/Accounts/LoginRequest.php deleted file mode 100644 index fd9632a..0000000 --- a/app/Http/Requests/Accounts/LoginRequest.php +++ /dev/null @@ -1,39 +0,0 @@ -guest(); - } - - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - 'email' => 'required|email', - 'password' => 'required', - ]; - } - - public function messages() - { - return [ - 'email.required' => 'Email harus diisi.', - 'password.required' => 'Password harus diisi.', - ]; - } -} diff --git a/app/Http/Requests/Accounts/UpdateProfileRequest.php b/app/Http/Requests/Accounts/UpdateProfileRequest.php deleted file mode 100644 index a972b81..0000000 --- a/app/Http/Requests/Accounts/UpdateProfileRequest.php +++ /dev/null @@ -1,38 +0,0 @@ -check(); - } - - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - return [ - 'name' => 'required|max:60' - ]; - } - - public function messages() - { - return [ - 'name.required' => 'Nama harus diisi.', - 'name.max' => 'Nama maksimal 60 karakter.', - ]; - } -} diff --git a/resources/lang/id/auth.php b/resources/lang/id/auth.php index f421747..18c7935 100644 --- a/resources/lang/id/auth.php +++ b/resources/lang/id/auth.php @@ -34,4 +34,6 @@ return [ 'old_password_failed' => 'Password lama tidak cocok!', 'welcome' => 'Selamat datang kembali :name.', 'logged_out' => 'Anda telah logout.', + 'profile' => 'Profil Saya', + 'profile_updated' => 'Profil sudah diupdate.', ]; diff --git a/resources/lang/id/user.php b/resources/lang/id/user.php index 448a768..6860c42 100644 --- a/resources/lang/id/user.php +++ b/resources/lang/id/user.php @@ -1,12 +1,21 @@ 'User', 'users' => 'Daftar User', 'user_id' => 'User ID', + 'profile' => 'Profil User', 'search' => 'Cari User: ketik nama', - 'religion' => 'Agama', - 'nationality' => 'Kewarganegaraan', + 'role' => 'Grup', + 'roles' => 'Grup', + 'search' => 'Ketik nama user lalu tekan Enter..', + 'found' => 'User ditemukan', + 'not_found' => 'User tidak ditemukan', + 'empty' => 'Belum ada User', + 'back_to_index' => 'Kembali ke Daftar User', + + // Actions 'create' => 'Input User Baru', 'created' => 'Input User baru telah berhasil.', 'show' => 'Detail User', @@ -16,25 +25,10 @@ return [ 'delete' => 'Hapus Data User', 'deleted' => 'Hapus data User telah berhasil.', 'undeleted' => 'Data User gagal dihapus.', - 'contact' => 'Kontak', - 'email' => 'Alamat Email', - 'phone' => 'Telp/Hp.', - 'role' => 'Grup', - 'roles' => 'Grup', - 'empty' => 'Belum ada User', - 'back_to_index' => 'Kembali ke Daftar User', - 'search' => 'Ketik nama user lalu tekan Enter..', - 'not_found' => 'User tidak ditemukan', - 'found' => 'User ditemukan', + + // Attributes + 'name' => 'Nama User', 'registered_at' => 'Terdaftar sejak', - 'permissions' => 'Hak Akses User', - 'pdob' => 'Tempat/Tanggal Lahir', - 'birth' => 'Lahir', - 'photo' => 'Foto', - 'pob' => 'Tempat Lahir', - 'dob' => 'Tanggal Lahir', - 'prefix' => 'Title Awal', - 'suffix' => 'Title Akhir', - 'login_id' => 'Login ID', - 'gender' => 'Jenis Kelamin', + 'email' => 'Alamat Email', + 'api_token' => 'API Token', ]; \ No newline at end of file diff --git a/resources/views/auth/change-password.blade.php b/resources/views/auth/change-password.blade.php index 342d225..8c3bd48 100644 --- a/resources/views/auth/change-password.blade.php +++ b/resources/views/auth/change-password.blade.php @@ -3,16 +3,17 @@ @section('title', trans('auth.change_password')) @section('content') -