First Commit
This commit is contained in:
commit
610aa1e202
4204 changed files with 636764 additions and 0 deletions
85
app/Http/Controllers/AdminUserController.php
Executable file
85
app/Http/Controllers/AdminUserController.php
Executable file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
class AdminUserController extends Controller
|
||||
{
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->middleware('superadmin');
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
//'values' => User::where('admin', 0)->get(),
|
||||
'values' => User::where('confirmation_code_remider', '!=', 2)->get(),
|
||||
];
|
||||
return view('admin.users', $data);
|
||||
}
|
||||
|
||||
public function edit($user_id)
|
||||
{
|
||||
$user = User::findOrFail($user_id);
|
||||
/*if(!$user->account){
|
||||
$user->account = new Account();
|
||||
}
|
||||
*/
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
return view('admin.user_edit', $data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = Input::all();
|
||||
$user = User::findOrFail($data['id']);
|
||||
|
||||
$user->admin = $data['admin'];
|
||||
$user->confirmed = isset($data['confirmed']) ? true : false;
|
||||
$user->active = isset($data['active']) ? true : false;
|
||||
$user->save();
|
||||
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect('/admin/users');
|
||||
|
||||
}
|
||||
|
||||
public function deleteUser($user_id)
|
||||
{
|
||||
$user = User::findOrFail($user_id);
|
||||
$this->userRepo->deleteUser($user);
|
||||
|
||||
\Session()->flash('alert-success', "Kontakt gelöscht");
|
||||
return redirect('/admin/users');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
69
app/Http/Controllers/Auth/LoginController.php
Executable file
69
app/Http/Controllers/Auth/LoginController.php
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
|
||||
protected function authenticated(Request $request, $user)
|
||||
{
|
||||
$user->last_login = date('Y-m-d H:i:s');
|
||||
$user->save();
|
||||
}
|
||||
protected function handleUserWasAuthenticated(Request $request, $throttles)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*
|
||||
//
|
||||
/* protected function validateLogin(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
$this->username() => 'required|exists:users,' . $this->username() . ',active,1',
|
||||
'password' => 'required',
|
||||
], [
|
||||
$this->username() . '.exists' => trans('validation.usernotactive'),
|
||||
]);
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
80
app/Http/Controllers/Auth/RegisterController.php
Executable file
80
app/Http/Controllers/Auth/RegisterController.php
Executable file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
public function showRegistrationForm()
|
||||
{
|
||||
//register off! - to login
|
||||
return redirect('login');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
39
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Controller.php
Executable file
13
app/Http/Controllers/Controller.php
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
67
app/Http/Controllers/CronController.php
Normal file
67
app/Http/Controllers/CronController.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class CronController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
// $this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->checkConfirmation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function checkConfirmation()
|
||||
{
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$next = date('Y-m-d H:i:s', strtotime('+3 week'));
|
||||
|
||||
$users = User::where('confirmed', '=', 0)->where('confirmation_code_to', '<', $now)->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
//delete user
|
||||
if ($user->confirmation_code_remider == 1) {
|
||||
$this->userRepo->deleteUser($user);
|
||||
|
||||
}
|
||||
//send new remider
|
||||
if ($user->confirmation_code_remider == 0) {
|
||||
Mail::to($user->email)->send(new MailVerifyAccount($user->confirmation_code, $user));
|
||||
$user->confirmation_code_to = $next;
|
||||
$user->confirmation_code_remider = 1;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
die("okay");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
76
app/Http/Controllers/DataTableController.php
Normal file
76
app/Http/Controllers/DataTableController.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\HTMLHelper;
|
||||
use DataTables;
|
||||
use App\User;
|
||||
|
||||
class DataTableController extends Controller
|
||||
{
|
||||
public function datatable()
|
||||
{
|
||||
return view('datatable');
|
||||
}
|
||||
|
||||
/*public function getLeads()
|
||||
{
|
||||
|
||||
$query = User::where('deleted_at', '=', null);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('first_name', function (User $user) {
|
||||
return $user->account ? $user->account->first_name : '';
|
||||
})
|
||||
->addColumn('last_name', function (User $user) {
|
||||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('action', function (User $user) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->orderColumn('confirmed', 'confirmed $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->rawColumns(['action', 'confirmed', 'active'])
|
||||
->make(true);
|
||||
}*/
|
||||
|
||||
public function getUsers()
|
||||
{
|
||||
//confirmation_code_remider is delete 2
|
||||
$query = User::where('deleted_at', '=', null);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (User $user) {
|
||||
return '<a href="' . route('admin_user_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('admin', function (User $user) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-default" data-id="'.$user->id.'" data-email="'.$user->email.'" data-admin="'.$user->admin.'" data-active="'.$user->active.'" data-confirmed="'.$user->confirmed.'">'.HTMLHelper::getRoleLabel($user->admin).'</a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('action_delete', function (User $user) {
|
||||
return '<a href="' . route('admin_user_delete', [$user->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="far fa-trash"></span></a>';
|
||||
})
|
||||
->orderColumn('confirmed', 'confirmed $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('admin', 'active $1')
|
||||
->rawColumns(['action_edit', 'admin', 'confirmed', 'active', 'action_delete'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**/
|
||||
120
app/Http/Controllers/HomeController.php
Executable file
120
app/Http/Controllers/HomeController.php
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\SfGuardUser;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use Request;
|
||||
use Input;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
}
|
||||
return redirect('home');
|
||||
|
||||
}
|
||||
|
||||
//login
|
||||
public function show()
|
||||
{
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
}
|
||||
$data = [
|
||||
'user' => Auth::user(),
|
||||
];
|
||||
return view('home', $data);
|
||||
}
|
||||
|
||||
|
||||
public function loadingModal(){
|
||||
|
||||
$data = Input::get('data');
|
||||
$target = Input::get('target');
|
||||
|
||||
$response = "";
|
||||
if($data == "data_protection"){
|
||||
$response = view('legal.data_protect_de')->render();
|
||||
}
|
||||
if($data == "imprint"){
|
||||
$response = view('legal.imprint_de')->render();
|
||||
}
|
||||
if(Request::ajax()) {
|
||||
return response()->json(['response' => $response, 'target'=>$target]);
|
||||
}
|
||||
abort(404);
|
||||
}
|
||||
|
||||
public function checkLogin($identify, $token)
|
||||
{
|
||||
if($identify){
|
||||
//user find by $identify
|
||||
$user = User::where('identify', '=', $identify)->first();
|
||||
if(!$user){
|
||||
return abort(404);
|
||||
}
|
||||
//user - check für from $sf_guard_user - old system
|
||||
$sf_guard_user = SfGuardUser::where('identify', '=', $identify)->first();
|
||||
if(!$sf_guard_user){
|
||||
return abort(404);
|
||||
}
|
||||
if($user->id != $sf_guard_user->user_id){
|
||||
return abort(404);
|
||||
|
||||
}
|
||||
if($sf_guard_user->token != $token){
|
||||
return abort(404);
|
||||
}
|
||||
$time = Carbon::parse($sf_guard_user->token_at);
|
||||
$now = Carbon::now();
|
||||
$duration = $time->diffInSeconds($now);
|
||||
|
||||
if($duration > 3){
|
||||
return abort(404);
|
||||
}
|
||||
$sf_guard_user->token = null;
|
||||
$sf_guard_user->token_at = null;
|
||||
$sf_guard_user->save();
|
||||
if(!Auth::check()){
|
||||
$user->last_login = now();
|
||||
$user->save();
|
||||
Auth::login($user);
|
||||
}
|
||||
if(Auth::check()){
|
||||
return redirect('/templates');
|
||||
}
|
||||
}
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
public function legalDataProtected()
|
||||
{
|
||||
return view('legal.data_protected');
|
||||
}
|
||||
|
||||
public function legalImprint()
|
||||
{
|
||||
return view('legal.imprint');
|
||||
}
|
||||
}
|
||||
27
app/Http/Controllers/TemplateController.php
Executable file
27
app/Http/Controllers/TemplateController.php
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
|
||||
class TemplateController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
if(Auth::check()) {
|
||||
|
||||
}
|
||||
return view('templates.index', ['title' => 'Page 2']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
179
app/Http/Controllers/TranslationController.php
Executable file
179
app/Http/Controllers/TranslationController.php
Executable file
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App;
|
||||
use File;
|
||||
use Input;
|
||||
|
||||
class TranslationController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $languagesPath;
|
||||
protected $directory_separator;
|
||||
protected $from;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->directory_separator = DIRECTORY_SEPARATOR;
|
||||
$this->languagesPath = App::langPath();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return redirect('admin/translate/edit/de');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $language
|
||||
* @param string $from
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function edit($language, $from = 'en')
|
||||
{
|
||||
$localisations = array_keys(config('localization.supportedLocales'));
|
||||
$files = $this->json_files($localisations);
|
||||
$translations = $this->translationsJson($language, $from);
|
||||
$show = "all";
|
||||
return view('translation.index', compact('files','translations', 'language', 'from', 'show'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $lang
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function update($language)
|
||||
{
|
||||
|
||||
$path = $this->resourcePath($this->languagesPath);
|
||||
$file = $path.$language.".json";
|
||||
$data = Input::all();
|
||||
$this->backup($path, $language.".json");
|
||||
unset($data['_token']);
|
||||
|
||||
$ret = [];
|
||||
//file make keys
|
||||
$source = json_decode(File::get($path."de.json"));
|
||||
foreach ($source as $key => $v){
|
||||
$skey = $this->sanitize($key);
|
||||
if(!empty($data[$skey])) {
|
||||
$ret[$key] = $data[$skey];
|
||||
}
|
||||
}
|
||||
$jsonData = json_encode($ret, TRUE);
|
||||
file_put_contents($file, $jsonData);
|
||||
return redirect()
|
||||
->route('admin_translate_edit', [$language])
|
||||
->with('message', 'Translation added successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $langs
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function json_files($localisations){
|
||||
$path = $this->resourcePath($this->languagesPath);
|
||||
$content = array();
|
||||
foreach ($localisations as $local){
|
||||
$file = File::get($path.$local.".json");
|
||||
if($file){
|
||||
$content[$local] = array('path'=>$path.$local.".json", 'content'=>json_encode($file));
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $language
|
||||
* @param $from
|
||||
* @return array
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function translationsJson($language, $from)
|
||||
{
|
||||
$path = $this->resourcePath($this->languagesPath);
|
||||
$file = array();
|
||||
$file['keys'] = (array) json_decode(File::get($path."de.json"));
|
||||
$file['keys'] = $this->sanitizeKey($file['keys']);
|
||||
$file['from'] = (array) json_decode(File::get($path.$from.".json"));
|
||||
$file['from'] = $this->sanitizeKey($file['from']);
|
||||
$file['dest'] = (array) json_decode(File::get($path.$language.".json"));
|
||||
$file['dest'] = $this->sanitizeKey($file['dest']);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function backup($path, $file)
|
||||
{
|
||||
|
||||
if (!File::exists(storage_path('language/'))) {
|
||||
File::makeDirectory(storage_path('language/'), 0755, true);
|
||||
}
|
||||
|
||||
return File::copy($path.$file, storage_path('language/'.time()."-".$file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @return string
|
||||
*/
|
||||
protected function resourcePath($path)
|
||||
{
|
||||
return "{$path}{$this->directory_separator}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $arr
|
||||
* @return mixed
|
||||
*/
|
||||
protected function sanitizeKey($arr){
|
||||
foreach ($arr as $key => $val){
|
||||
unset($arr[$key]);
|
||||
$arr[$this->sanitize($key)] = $val;
|
||||
}
|
||||
return $arr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
* @param bool $force_lowercase
|
||||
* @param bool $anal
|
||||
* @return mixed|null|string|string[]
|
||||
*/
|
||||
protected function sanitize($string, $force_lowercase = true, $anal = false)
|
||||
{
|
||||
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]",
|
||||
"}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—",
|
||||
"—", "–", ",", "<", ".", ">", "/", "?");
|
||||
$clean = trim(str_replace($strip, "", strip_tags($string)));
|
||||
$clean = preg_replace('/\s+/', "_", $clean);
|
||||
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ;
|
||||
|
||||
return ($force_lowercase) ?
|
||||
(function_exists('mb_strtolower')) ?
|
||||
mb_strtolower($clean, 'UTF-8') :
|
||||
strtolower($clean) :
|
||||
$clean;
|
||||
}
|
||||
|
||||
}
|
||||
96
app/Http/Controllers/UserDataController.php
Executable file
96
app/Http/Controllers/UserDataController.php
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use App\Repositories\UserRepository;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Validator;
|
||||
|
||||
|
||||
class UserDataController extends Controller
|
||||
{
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function userEdit(){
|
||||
$user = Auth::user();
|
||||
|
||||
/*if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
}*/
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
return view('user.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function userEditStore(){
|
||||
|
||||
$user = Auth::user();
|
||||
/*if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
}*/
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'last_name' => 'required|max:255',
|
||||
'country_id' => 'required|integer|min:1',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
);
|
||||
|
||||
if(Input::get('company') == 1){
|
||||
$rules['company_name'] = 'required|max:255';
|
||||
$rules['company_country_id'] = 'required|integer|min:1';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.edit', $data)->withErrors($validator);
|
||||
|
||||
} else {
|
||||
$this->userRepo->update(Input::all());
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect('/user/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function userDataAcceptedForm(){
|
||||
$user = Auth::user();
|
||||
|
||||
if(Input::get('sender_accepted_infos') == "on"){
|
||||
$user->agreement = now();
|
||||
}else {
|
||||
$user->agreement = null;
|
||||
}
|
||||
|
||||
$user->save();
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
}
|
||||
73
app/Http/Controllers/UserDeleteController.php
Executable file
73
app/Http/Controllers/UserDeleteController.php
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Validator;
|
||||
use Input;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Repositories\UserRepository;
|
||||
|
||||
|
||||
|
||||
class UserDeleteController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
* @param UserRepository $userRepo
|
||||
*/
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function deleteAccount(){
|
||||
return view('user.delete_account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function deleteAccountAction(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$rules = array(
|
||||
'old_password' => 'required|old_password:' . Auth::user()->password,
|
||||
);
|
||||
|
||||
Validator::extend('old_password', function ($attribute, $value, $parameters, $validator) {
|
||||
|
||||
return Hash::check($value, current($parameters));
|
||||
|
||||
});
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.delete_account')->withErrors($validator);
|
||||
|
||||
}else{
|
||||
$this->userRepo->deleteUser($user);
|
||||
//make delete
|
||||
Auth::logout();
|
||||
\Session()->flash('alert-danger', __('account deleted'));
|
||||
return redirect(route('home'));
|
||||
}
|
||||
}
|
||||
}
|
||||
214
app/Http/Controllers/UserUpdateEmailController.php
Executable file
214
app/Http/Controllers/UserUpdateEmailController.php
Executable file
|
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Validator;
|
||||
use Input;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Connection;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailActivateUser;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class UserUpdateEmailController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $db;
|
||||
|
||||
protected $table = 'user_update_emails';
|
||||
|
||||
protected $resendAfter = 60; //1min
|
||||
|
||||
|
||||
public function __construct(Connection $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('user.update_email');
|
||||
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:' . Auth::user()->id,
|
||||
//'email-confirm' => 'required|same:email',
|
||||
);
|
||||
|
||||
Validator::extend('users_update_email', function ($attribute, $value, $parameters, $validator) {
|
||||
if($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
});
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
$messages = $validator->messages();
|
||||
|
||||
return view('user.update_email')->withErrors($validator);
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$this->sendActivationMail($user, $request->all());
|
||||
\Session()->flash('alert-success', __('We sent you an activation code. Check your email!'));
|
||||
return redirect(route('user_update_email'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* public function adminChangeMail($user_id)
|
||||
{
|
||||
if(!Auth::user()->isAdmin()){
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
'user' => User::findOrFail($user_id),
|
||||
];
|
||||
return view('admin.change_email', $data);
|
||||
|
||||
}
|
||||
public function adminUpdateMail(Request $request, $user_id)
|
||||
{
|
||||
if(!Auth::user()->isAdmin()){
|
||||
abort(404);
|
||||
}
|
||||
$user = User::findOrFail($user_id);
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
|
||||
$rules = array(
|
||||
'email' => 'required|string|email|max:255|unique:users|confirmed|users_update_email:' . $user->id,
|
||||
//'email-confirm' => 'required|same:email',
|
||||
);
|
||||
|
||||
Validator::extend('users_update_email', function ($attribute, $value, $parameters, $validator) {
|
||||
if($this->db->table($this->table)->where('email', '=', $value)->where('user_id', '!=', $parameters[0])->count()){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
});
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
$messages = $validator->messages();
|
||||
|
||||
return view('admin.change_email', $data)->withErrors($validator);
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$this->sendActivationMail($user, $request->all());
|
||||
\Session()->flash('alert-success', __('An activation code was sent to the account by e-mail!'));
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public function activateMail($token)
|
||||
{
|
||||
|
||||
if ($updateEmail = $this->getUpdateEmailByToken($token)) {
|
||||
$user = User::findOrFail($updateEmail->user_id);
|
||||
if($user->id == $updateEmail->user_id){
|
||||
$user->fill([
|
||||
'email' => $updateEmail->email
|
||||
])->save();
|
||||
$this->deleteUpdateEmail($token);
|
||||
//Login!
|
||||
Auth::login($user);
|
||||
\Session()->flash('alert-success', __('Your e-mail has been changed.'));
|
||||
return redirect('/home');
|
||||
|
||||
}
|
||||
}
|
||||
return redirect('/home');
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
public function sendActivationMail($user, array $data)
|
||||
{
|
||||
$token = $this->createActivation($user, $data);
|
||||
Mail::to($data['email'])->send(new MailActivateUser($token, $user));
|
||||
}
|
||||
|
||||
|
||||
protected function getToken()
|
||||
{
|
||||
return hash_hmac('sha256', str_random(40), config('app.key'));
|
||||
}
|
||||
|
||||
public function createActivation($user, array $data)
|
||||
{
|
||||
|
||||
$updateEmail = $this->getUpdateEmail($user);
|
||||
|
||||
if (!$updateEmail) {
|
||||
return $this->createToken($user, $data);
|
||||
}
|
||||
return $this->regenerateToken($user, $data);
|
||||
|
||||
}
|
||||
|
||||
private function regenerateToken($user, array $data)
|
||||
{
|
||||
|
||||
$token = $this->getToken();
|
||||
$this->db->table($this->table)->where('user_id', $user->id)->update([
|
||||
'email' => $data['email'],
|
||||
'token' => $token,
|
||||
'created_at' => new Carbon()
|
||||
]);
|
||||
return $token;
|
||||
}
|
||||
|
||||
private function createToken($user, array $data)
|
||||
{
|
||||
$token = $this->getToken();
|
||||
$this->db->table($this->table)->insert([
|
||||
'user_id' => $user->id,
|
||||
'email' => $data['email'],
|
||||
'token' => $token,
|
||||
'created_at' => new Carbon()
|
||||
]);
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function getUpdateEmail($user)
|
||||
{
|
||||
return $this->db->table($this->table)->where('user_id', $user->id)->first();
|
||||
}
|
||||
|
||||
|
||||
public function getUpdateEmailByToken($token)
|
||||
{
|
||||
return $this->db->table($this->table)->where('token', $token)->first();
|
||||
}
|
||||
|
||||
public function deleteUpdateEmail($token)
|
||||
{
|
||||
$this->db->table($this->table)->where('token', $token)->delete();
|
||||
}
|
||||
}
|
||||
112
app/Http/Controllers/UserUpdatePasswordController.php
Executable file
112
app/Http/Controllers/UserUpdatePasswordController.php
Executable file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Validator;
|
||||
use Input;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class UserUpdatePasswordController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function updatePassword()
|
||||
{
|
||||
return view('user.update_password');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function updatePasswordStore(Request $request)
|
||||
{
|
||||
$rules = array(
|
||||
'old_password' => 'required|old_password:' . Auth::user()->password,
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
);
|
||||
|
||||
Validator::extend('old_password', function ($attribute, $value, $parameters, $validator) {
|
||||
|
||||
return Hash::check($value, current($parameters));
|
||||
|
||||
});
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.update_password')->withErrors($validator);
|
||||
|
||||
}else{
|
||||
$request->user()->fill([
|
||||
'password' => Hash::make($request->password)
|
||||
])->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('user_update_password'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function updatePasswordFirst(){
|
||||
if(!Auth::user()->isPasswort()){
|
||||
return view('user.update_password_first');
|
||||
}
|
||||
return redirect(route('user_update_password'));
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Update the password for the user.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function updatePasswordFirstStore(Request $request)
|
||||
{
|
||||
$rules = array(
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
);
|
||||
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.update_password_first')->withErrors($validator);
|
||||
|
||||
}else{
|
||||
$request->user()->fill([
|
||||
'password' => Hash::make($request->password)
|
||||
])->save();
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect('/home');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue