Page MenuHomeDevCentral

No OneTemporary

diff --git a/app/Console/Commands/AccountDump.php b/app/Console/Commands/AccountDump.php
index f633c46..de96410 100644
--- a/app/Console/Commands/AccountDump.php
+++ b/app/Console/Commands/AccountDump.php
@@ -1,60 +1,60 @@
<?php
namespace AuthGrove\Console\Commands;
use Illuminate\Console\Command;
use AuthGrove\User as User;
class AccountDump extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'account:dump {--format=human}';
/**
* The console command description.
*
* @var string
*/
- protected $description = 'Dumps the accounts list.';
+ protected $description = 'Dump the accounts list';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$format = $this->option('format');
$attributes = User::getDefaultAttributes();
$users = User::all($attributes)->toArray();
switch ($format) {
case "human":
$headers = array_map('\AuthGrove\User::localizeAttribute', $attributes);
$this->table($headers, $users);
break;
case "json":
echo json_encode($users);
break;
default:
$this->error("Unknown format: $format");
}
}
}
diff --git a/app/Console/Commands/AccountInfo.php b/app/Console/Commands/AccountInfo.php
index 2856c3e..f6f55d2 100644
--- a/app/Console/Commands/AccountInfo.php
+++ b/app/Console/Commands/AccountInfo.php
@@ -1,88 +1,88 @@
<?php
namespace AuthGrove\Console\Commands;
use Illuminate\Console\Command;
use AuthGrove\User;
use AuthGrove\Console\Services\AccountHelpers as AccountHelpers;
class AccountInfo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'account:info {user} {--format=human}';
/**
* The console command description.
*
* @var string
*/
- protected $description = 'Get information about an account.';
+ protected $description = 'Get information about an account';
/**
* The length of a padded localized attribute
* @var int
*/
const ATTRIBUTE_LEN = 21;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Prints a padded "attribute: value" line.
*
* @param string $attribute The attribute
* @param string $value The value for this attribute
*/
protected function printInformationAttribute ($attribute, $value) {
$line = \Keruald\mb_str_pad(
AccountHelpers::localizeUserAttribute($attribute),
self::ATTRIBUTE_LEN
);
$line .= $value;
$this->info($line);
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$format = $this->option('format');
$user = AccountHelpers::findUser($this->argument('user'));
if ($user === null) {
$this->error("User not found.");
return;
}
$information = $user->getInformation();
switch ($format) {
case "human":
foreach ($user->getInformation() as $attribute => $value) {
$this->printInformationAttribute($attribute, $value);
}
break;
case "json":
echo json_encode($information), "\n";
break;
default:
$this->error("Unknown format: $format");
}
}
}
diff --git a/app/Console/Commands/AccountReset.php b/app/Console/Commands/AccountReset.php
index ad796ad..245e95a 100644
--- a/app/Console/Commands/AccountReset.php
+++ b/app/Console/Commands/AccountReset.php
@@ -1,130 +1,130 @@
<?php
namespace AuthGrove\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Contracts\Auth\PasswordBroker;
use Illuminate\Support\Facades\Password;
use AuthGrove\User;
use AuthGrove\Console\Services\AccountHelpers;
class AccountReset extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'account:reset {user} {--subject=} {--format=human}';
/**
* The console command description.
*
* @var string
*/
- protected $description = 'Sends a mail with a reset password link for an account.';
+ protected $description = 'Send a mail with a reset password link for an account';
/**
* The user e-mail
*
* @var string
*/
private $email;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Gets e-mail subject from command line option or default l10n
*
* @return string the e-mail subject
*/
public function getEmailSubject () {
$subject = $this->option('subject');
if ($subject === null) {
return trans('emails.reset-password-subject');
}
return $subject;
}
/**
* Sends a reset passsword e-mail
*
* @return bool true if a mail has been sent, false if the user is invalid
*/
public function sendResetMail () {
//Information we need for this mail
$subject = $this->getEmailSubject();
$credentials = [
'email' => $this->email
];
//Tries to send the mail
$response = Password::sendResetLink($credentials, function($m) use ($subject)
{
$m->subject($subject);
});
//Handles password broker response, returning true on success
switch ($response) {
case PasswordBroker::RESET_LINK_SENT:
return true;
case PasswordBroker::INVALID_USER:
return false;
default:
throw new Exception("Unhandled password broker response: " . $response);
}
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//Gets the information
$user = AccountHelpers::findUser($this->argument('user'));
if ($user === null) {
$this->error("User not found.");
return;
}
$this->email = $user->getInformation()['email'];
//Operation
$success = $this->sendResetMail();
if (!$success) {
$this->error("The user has been found, but the password broker considers this user is invalid.");
exit;
}
//Regular output
$format = $this->option('format');
switch ($format) {
case "human":
$this->info("A reset link mail has been sent to $this->email.");
break;
case "json":
echo json_encode([
"result" => "ok",
"email" => $this->email
]);
echo PHP_EOL;
break;
default:
$this->error("Unknown format: $format");
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Oct 12, 07:15 (19 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3065378
Default Alt Text
(7 KB)

Event Timeline