Skip to content
This repository has been archived by the owner on Mar 25, 2019. It is now read-only.

Commit

Permalink
Merge pull request #3 from ReFlar/analysis-zeLQDA
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
Charlie committed Apr 8, 2017
2 parents b672b4b + 48e427a commit d32c36f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
18 changes: 10 additions & 8 deletions src/Api/Controllers/ServeStrikeController.php
@@ -1,4 +1,5 @@
<?php
<?php

/*
* This file is part of reflar/user-management.
*
Expand All @@ -12,38 +13,39 @@

namespace Reflar\UserManagement\Api\Controllers;

use Reflar\UserManagement\Api\Serializers\StrikeSerializer;
use Reflar\UserManagement\Commands\DeleteStrike;
use Reflar\UserManagement\Commands\ServeStrike;
use Flarum\Api\Controller\AbstractResourceController;
use Illuminate\Contracts\Bus\Dispatcher;
use Psr\Http\Message\ServerRequestInterface;
use Reflar\UserManagement\Api\Serializers\StrikeSerializer;
use Reflar\UserManagement\Commands\DeleteStrike;
use Reflar\UserManagement\Commands\ServeStrike;
use Tobscure\JsonApi\Document;
use Zend\Diactoros\UploadedFile;

class ServeStrikeController extends AbstractResourceController
{
public $serializer = StrikeSerializer::class;
protected $bus;

public function __construct(Dispatcher $bus)
{
$this->bus = $bus;
}

protected function data(ServerRequestInterface $request, Document $document)
{
$actor = $request->getAttribute('actor');
$id = array_get($request->getParsedBody(), 'id');
if (isset($id)) {
return $this->bus->dispatch(
return $this->bus->dispatch(
new DeleteStrike($id, $actor)
);
} else {
$post_id = array_get($request->getParsedBody(), 'post_id');
$reason = array_get($request->getParsedBody(), 'reason');

return $this->bus->dispatch(
new ServeStrike($post_id, $reason, $actor)
);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/RegisterUser.php
Expand Up @@ -39,7 +39,7 @@ public function __construct(User $actor, array $data)
{
if (app()->make(SettingsRepositoryInterface::class)->get('ReFlar-recaptcha') == true) {
app()->make(RecaptchaValidator::class)->assertValid([
'g-recaptcha-response' => array_get($data, 'attributes.g-recaptcha-response')
'g-recaptcha-response' => array_get($data, 'attributes.g-recaptcha-response'),
]);
}
$this->actor = $actor;
Expand Down
3 changes: 1 addition & 2 deletions src/Commands/RegisterUserHandler.php
Expand Up @@ -104,9 +104,8 @@ public function handle(RegisterUser $command)
$age = array_get($data, 'attributes.age');
$gender = ucfirst(strtolower(array_get($data, 'attributes.gender')));


if ($this->settings->get('ReFlar-emailRegEnabled') == true) {
$email = $username . '@' . $username . '.com';
$email = $username.'@'.$username.'.com';
}
// If a valid authentication token was provided as an attribute,
// then we won't require the user to choose a password.
Expand Down
2 changes: 1 addition & 1 deletion src/Validators/UserValidator.php
Expand Up @@ -61,7 +61,7 @@ protected function getRules()
];

$this->settings = app()->make(SettingsRepositoryInterface::class);

if ($this->settings->get('ReFlar-emailRegEnabled') == false) {
$validator['email'] = ['required', 'email', 'unique:users,email'.$idSuffix];
}
Expand Down

0 comments on commit d32c36f

Please sign in to comment.