-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
990 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: vendor/bin/heroku-php-nginx -C nginx.conf frontend/web | ||
web: vendor/bin/heroku-php-nginx -C heroku/nginx.conf frontend/web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return [ | ||
'main' => [ | ||
'class' => 'backend\modules\main\Module', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace backend\controllers; | ||
|
||
use common\exceptions; | ||
use yii\web\Controller; | ||
use yii; | ||
|
||
abstract class AuthController extends Controller | ||
{ | ||
public function init() | ||
{ | ||
parent::init(); | ||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||
} | ||
|
||
/** | ||
* @param yii\base\Action $action | ||
* @return bool | ||
* @throws exceptions\AuthorizationException | ||
* @throws yii\web\BadRequestHttpException | ||
*/ | ||
public function beforeAction($action) | ||
{ | ||
$token = Yii::$app->request->getQueryParam('oauth_token'); | ||
|
||
|
||
if (!Yii::$app->user->loginByAccessToken($token)) { | ||
throw exceptions\AuthorizationException::invalidToken(); | ||
} | ||
|
||
return parent::beforeAction($action); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace backend\modules\main; | ||
|
||
class Module extends \yii\base\Module | ||
{ | ||
public $controllerNamespace = 'frontend\modules\main\controllers'; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
// custom initialization code goes here | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace backend\modules\main\controllers; | ||
|
||
use yii\web\Controller; | ||
|
||
class SiteController extends Controller | ||
{ | ||
public function actionIndex() | ||
{ | ||
return $this->render('index'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace backend\models; | ||
|
||
use Yii; | ||
use yii\base\Model; | ||
|
||
/** | ||
* ContactForm is the model behind the contact form. | ||
*/ | ||
class ContactForm extends Model | ||
{ | ||
public $name; | ||
public $email; | ||
public $subject; | ||
public $body; | ||
public $verifyCode; | ||
|
||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
// name, email, subject and body are required | ||
[['name', 'email', 'subject', 'body'], 'required'], | ||
// email has to be a valid email address | ||
['email', 'email'], | ||
// verifyCode needs to be entered correctly | ||
['verifyCode', 'captcha'], | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function attributeLabels() | ||
{ | ||
return [ | ||
'verifyCode' => 'Verification Code', | ||
]; | ||
} | ||
|
||
/** | ||
* Sends an email to the specified email address using the information collected by this model. | ||
* | ||
* @param string $email the target email address | ||
* @return bool whether the email was sent | ||
*/ | ||
public function sendEmail($email) | ||
{ | ||
return Yii::$app->mailer->compose() | ||
->setTo($email) | ||
->setFrom([$this->email => $this->name]) | ||
->setSubject($this->subject) | ||
->setTextBody($this->body) | ||
->send(); | ||
} | ||
} |
0
backend/views/site/error.php → backend/modules/main/views/site/error.php
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace backend\modules\user; | ||
|
||
class Module extends \yii\base\Module | ||
{ | ||
public $controllerNamespace = 'backend\modules\user\controllers'; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
// custom initialization code goes here | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace backend\modules\user\api; | ||
|
||
use backend\modules\user\datatypes\UserStructure; | ||
use yii; | ||
|
||
|
||
class User | ||
{ | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function info(): array | ||
{ | ||
$user = new UserStructure( | ||
Yii::$app->user->getIdentity() | ||
); | ||
|
||
return $user->serialize(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace backend\modules\user\controllers; | ||
|
||
use backend\controllers\AuthController; | ||
use backend\modules\user\api\User as UserApi; | ||
|
||
|
||
class UserController extends AuthController | ||
{ | ||
public $api; | ||
|
||
public function beforeAction($action) | ||
{ | ||
if (parent::beforeAction($action)) { | ||
$this->api = new UserApi(); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace backend\modules\user\datatypes; | ||
|
||
use common\datatypes\Structure; | ||
use common\models\User; | ||
|
||
class UserStructure implements Structure | ||
{ | ||
/** | ||
* @var User | ||
*/ | ||
private $user; | ||
|
||
public function __construct($user) | ||
{ | ||
$this->user = $user; | ||
} | ||
|
||
public function serialize(): array | ||
{ | ||
$user = [ | ||
'id' => $this->user->id, | ||
'email' => $this->user->email, | ||
'username' => $this->user->username, | ||
'first_name' => $this->user->first_name, | ||
'last_name' => $this->user->last_name, | ||
'photo_url' => $this->user->photo_url, | ||
'timezone' => $this->user->timezone, | ||
'locale' => $this->user->locale, | ||
'created_at' => $this->user->created_at, | ||
'updated_at' => $this->user->updated_at, | ||
]; | ||
|
||
// if($) | ||
|
||
return $user; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace common\clients; | ||
|
||
use Yii; | ||
use yii\authclient\AuthAction as MainAuth; | ||
|
||
class AuthAction extends MainAuth | ||
{ | ||
public function redirect($url, $enforceRedirect = true) | ||
{ | ||
$viewFile = __DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'redirect.php'; | ||
$viewData = [ | ||
'token' => Yii::$app->session->get('auth_token'), | ||
'url' => $url, | ||
'enforceRedirect' => $enforceRedirect, | ||
]; | ||
$response = Yii::$app->getResponse(); | ||
$response->content = Yii::$app->getView()->renderFile($viewFile, $viewData); | ||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace common\clients; | ||
|
||
use Yii; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace common\clients; | ||
|
||
use yii\authclient\SessionStateStorage; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
use yii\helpers\Json; | ||
|
||
/* @var $this \yii\base\View */ | ||
/* @var $token string */ | ||
?> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script> | ||
function popupWindowRedirect(url, enforceRedirect, token) | ||
{ | ||
if (window.opener && !window.opener.closed) { | ||
window.opener.localStorage.setItem('token', token); | ||
if (enforceRedirect === undefined || enforceRedirect) { | ||
window.opener.location = url; | ||
} | ||
window.opener.focus(); | ||
window.close(); | ||
} else { | ||
window.localStorage.setItem('token', token); | ||
} | ||
} | ||
popupWindowRedirect(<?= Json::htmlEncode($url) ?>, <?= Json::htmlEncode($enforceRedirect) ?>, <?= Json::htmlEncode($token) ?>); | ||
</script> | ||
</head> | ||
<body> | ||
|
||
<div id="token" data-token="<?= Json::htmlEncode($token) ?>"></div> | ||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
namespace common\datatypes; | ||
|
||
interface Structure | ||
{ | ||
public function serialize(): array; | ||
} |
Oops, something went wrong.