CompanyApiLogin::getLoginInfo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 1
1
<?php
2
namespace SimpleCMS\Company\Packages;
3
4
use Illuminate\Support\Facades\Auth;
5
use Illuminate\Support\Facades\Hash;
6
use SimpleCMS\Company\Models\CompanyAccount;
7
use SimpleCMS\Framework\Exceptions\SimpleException;
8
use SimpleCMS\Framework\Packages\Finger\Finger;
9
use Symfony\Component\HttpFoundation\RedirectResponse;
10
11
12
class CompanyApiLogin
13
{
14
    /**
15
     * 获取登录token及基础信息
16
     * @param \SimpleCMS\Company\Models\CompanyAccount $account
17
     * @return array
18
     */
19
    public static function getLoginInfo(CompanyAccount $account): array
20
    {
21
        $token = $account->createToken('company_api');
22
        return [
23
            'token' => $token->plainTextToken,
24
            'finger' => Finger::getFinger(),
25
            'user' => (new CompanyAuthenticatable)->getAccount($account)
26
        ];
27
    }
28
29
}