Skip to content

Commit

Permalink
changed and modified for Linphone user registry
Browse files Browse the repository at this point in the history
  • Loading branch information
capitalfuse committed May 29, 2020
1 parent 15d2b98 commit 106b533
Show file tree
Hide file tree
Showing 138 changed files with 20,964 additions and 285 deletions.
Empty file modified .editorconfig 100644 → 100755
Empty file.
Empty file modified .github/FUNDING.yml 100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/bug_report.md 100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/feature_request.md 100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/project-questions-and-help.md 100644 → 100755
Empty file.
Empty file modified .styleci.yml 100644 → 100755
Empty file.
Empty file modified _config.yml 100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions app/Http/Controllers/AdminDetailsController.php
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers;

use App\Models\User;
use App\Models\Account;
use Illuminate\Support\Facades\Route;

class AdminDetailsController extends Controller
Expand Down Expand Up @@ -39,7 +39,7 @@ public function listRoutes()
*/
public function activeUsers()
{
$users = User::count();
$users = Account::count();

return view('pages.admin.active-users', ['users' => $users]);
}
Expand Down
20 changes: 10 additions & 10 deletions app/Http/Controllers/Auth/ActivateController.php
Expand Up @@ -5,7 +5,7 @@
use App\Http\Controllers\Controller;
use App\Models\Activation;
use App\Models\Profile;
use App\Models\User;
use App\Models\Account;
use App\Traits\ActivationTrait;
use App\Traits\CaptureIpTrait;
use Auth;
Expand Down Expand Up @@ -113,7 +113,7 @@ public static function activeRedirect($user, $currentRoute)
public function initial()
{
$user = Auth::user();
$lastActivation = Activation::where('user_id', $user->id)->get()->last();
$lastActivation = Activation::where('account_id', $user->id)->get()->last();
$currentRoute = Route::currentRouteName();

$rCheck = $this->activeRedirect($user, $currentRoute);
Expand All @@ -137,7 +137,7 @@ public function initial()
public function activationRequired()
{
$user = Auth::user();
$lastActivation = Activation::where('user_id', $user->id)->get()->last();
$lastActivation = Activation::where('account_id', $user->id)->get()->last();
$currentRoute = Route::currentRouteName();

$rCheck = $this->activeRedirect($user, $currentRoute);
Expand All @@ -146,7 +146,7 @@ public function activationRequired()
}

if ($user->activated === false) {
$activationsCount = Activation::where('user_id', $user->id)
$activationsCount = Activation::where('account_id', $user->id)
->where('created_at', '>=', Carbon::now()->subHours(config('settings.timePeriod')))
->count();

Expand Down Expand Up @@ -193,7 +193,7 @@ public function activate($token)
}

$activation = Activation::where('token', $token)->get()
->where('user_id', $user->id)
->where('account_id', $user->id)
->first();

if (empty($activation)) {
Expand All @@ -211,7 +211,7 @@ public function activate($token)
$user->profile()->save($profile);
$user->save();

$allActivations = Activation::where('user_id', $user->id)->get();
$allActivations = Activation::where('account_id', $user->id)->get();
foreach ($allActivations as $anActivation) {
$anActivation->delete();
}
Expand All @@ -237,11 +237,11 @@ public function activate($token)
public function resend()
{
$user = Auth::user();
$lastActivation = Activation::where('user_id', $user->id)->get()->last();
$lastActivation = Activation::where('account_id', $user->id)->get()->last();
$currentRoute = Route::currentRouteName();

if ($user->activated === false) {
$activationsCount = Activation::where('user_id', $user->id)
$activationsCount = Activation::where('account_id', $user->id)
->where('created_at', '>=', Carbon::now()->subHours(config('settings.timePeriod')))
->count();

Expand Down Expand Up @@ -282,8 +282,8 @@ public function exceeded()
$user = Auth::user();
$currentRoute = Route::currentRouteName();
$timePeriod = config('settings.timePeriod');
$lastActivation = Activation::where('user_id', $user->id)->get()->last();
$activationsCount = Activation::where('user_id', $user->id)
$lastActivation = Activation::where('account_id', $user->id)->get()->last();
$activationsCount = Activation::where('account_id', $user->id)
->where('created_at', '>=', Carbon::now()->subHours($timePeriod))
->count();

Expand Down
28 changes: 19 additions & 9 deletions app/Http/Controllers/Auth/RegisterController.php
Expand Up @@ -4,7 +4,8 @@

use App\Http\Controllers\Controller;
use App\Models\Profile;
use App\Models\User;
use App\Models\Account;
use App\Models\Password;
use App\Traits\ActivationTrait;
use App\Traits\CaptchaTrait;
use App\Traits\CaptureIpTrait;
Expand Down Expand Up @@ -67,20 +68,22 @@ protected function validator(array $data)
return Validator::make(
$data,
[
'name' => 'required|max:255|unique:users',
'username' => 'required|max:255|unique:accounts',
'first_name' => '',
'last_name' => '',
'email' => 'required|email|max:255|unique:users',
'domain' => 'required|max:64',
'email' => 'required|email|max:255|unique:accounts',
'password' => 'required|min:6|max:30|confirmed',
'password_confirmation' => 'required|same:password',
'g-recaptcha-response' => '',
'captcha' => 'required|min:1',
],
[
'name.unique' => trans('auth.userNameTaken'),
'name.required' => trans('auth.userNameRequired'),
'username.unique' => trans('auth.userNameTaken'),
'username.required' => trans('auth.userNameRequired'),
'first_name.required' => trans('auth.fNameRequired'),
'last_name.required' => trans('auth.lNameRequired'),
'domain.required' => trans('auth.domainRequired'),
'email.required' => trans('auth.emailRequired'),
'email.email' => trans('auth.emailInvalid'),
'password.required' => trans('auth.passwordRequired'),
Expand All @@ -97,7 +100,7 @@ protected function validator(array $data)
*
* @param array $data
*
* @return User
* @return Account
*/
protected function create(array $data)
{
Expand All @@ -111,21 +114,28 @@ protected function create(array $data)
$activated = true;
}

$user = User::create([
'name' => $data['name'],
$user = Account::create([
'username' => $data['username'],
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'domain' => $data['domain'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'token' => str_random(64),
'signup_ip_address' => $ipAddress->getClientIp(),
'activated' => $activated,
]);

$password = Password::create ([
'account_id' => $user->id,
'password' => hash('sha256', $user->username.':'.$user->domain.':'.$data['password']),
'algorithm' => 'SHA-256',
]);

$user->attachRole($role);
$this->initiateEmailActivation($user);

if (! config('settings.activation')) {
$user->password()->save($password);
$profile = new Profile();
$user->profile()->save($profile);
$user->save();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/ResetPasswordController.php
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use App\Traits\ResetsPasswords;

class ResetPasswordController extends Controller
{
Expand Down
24 changes: 17 additions & 7 deletions app/Http/Controllers/Auth/SocialController.php
Expand Up @@ -5,13 +5,14 @@
use App\Http\Controllers\Controller;
use App\Models\Profile;
use App\Models\Social;
use App\Models\User;
use App\Models\Account;
use App\Traits\ActivationTrait;
use App\Traits\CaptureIpTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
use jeremykenedy\LaravelRoles\Models\Role;
use Laravel\Socialite\Facades\Socialite;
use Faker\Factory;

class SocialController extends Controller
{
Expand Down Expand Up @@ -61,7 +62,7 @@ public function getSocialHandle($provider, Request $request)
$socialUserObject = Socialite::driver($provider)->user();

// Check if email is already registered
$userCheck = User::where('email', '=', $socialUserObject->email)->first();
$userCheck = Account::where('email', '=', $socialUserObject->email)->first();

$email = $socialUserObject->email;

Expand Down Expand Up @@ -94,19 +95,28 @@ public function getSocialHandle($provider, Request $request)

// Check to make sure username does not already exist in DB before recording
$username = $this->checkUserName($username, $email);
$faker = Factory::create();

$user = User::create([
'name' => $username,
$user = Account::create([
'username' => $username,
'first_name' => $fullname[0],
'last_name' => $fullname[1],
'domain' => $faker->domainName,
'email' => $email,
'password' => bcrypt(str_random(40)),
'token' => str_random(64),
'activated' => true,
'signup_sm_ip_address' => $ipAddress->getClientIp(),

]);

$password = Password::create ([
'account_id' => $user->id,
'password' => hash('sha256', $user->username.':'.$user->domain.':password'),
'algorithm' => 'SHA-256',
]);

$user->password()->save($password);

$socialData->social_id = $socialUserObject->id;
$socialData->provider = $provider;
$user->social()->save($socialData);
Expand Down Expand Up @@ -157,13 +167,13 @@ public function getSocialHandle($provider, Request $request)
*/
public function checkUserName($username, $email)
{
$userNameCheck = User::where('name', '=', $username)->first();
$userNameCheck = Account::where('name', '=', $username)->first();

if ($userNameCheck) {
$i = 1;
do {
$username = $this->generateUserName($username);
$newCheck = User::where('name', '=', $username)->first();
$newCheck = Account::where('name', '=', $username)->first();

if ($newCheck == null) {
$newCheck = 0;
Expand Down

0 comments on commit 106b533

Please sign in to comment.