Files
SmartHomePHP/components/WebSocketAuth.php
Alex Solomaha 7ebad90e63 Some work
2016-09-02 21:13:00 +03:00

30 lines
448 B
PHP

<?php
namespace app\components;
use app\models\User;
use Yii;
class WebSocketAuth
{
/**
* @return null|string
*/
public static function getAuthKey()
{
$user = User::findOne(Yii::$app->user->id);
if (!$user) {
return null;
}
$auth_key = $user->auth_key;
// Regenerate auth key
$user->generateAuthKey();
$user->save();
return $auth_key;
}
}