mirror of
https://github.com/CyanoFresh/SmartHomePHP.git
synced 2026-03-03 08:34:02 +01:00
30 lines
448 B
PHP
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;
|
|
}
|
|
}
|