登录校验

This commit is contained in:
2022-11-01 13:28:08 +08:00
parent c23de98690
commit 719a9ff89d
8 changed files with 583 additions and 7 deletions

View File

@@ -4,15 +4,30 @@ namespace App\Api\Controllers;
use App\Api\Resources\AuthResource;
use App\Models\User;
use BitWasp\Bitcoin\Address\PayToPubKeyHashAddress;
use BitWasp\Bitcoin\Key\Factory\HierarchicalKeyFactory;
use BitWasp\Bitcoin\Mnemonic\Bip39\Bip39SeedGenerator;
use Illuminate\Http\Request;
class AuthController extends Controller
{
public function login(Request $request)
{
$address = $request->address;
$address = $request->address;
$mnemonic = $request->mnemonic;
$address = '12dUut3dG5xWi6JPDMjSSK6s2JPcfeKYL1';
// $address = '12dUut3dG5xWi6JPDMjSSK6s2JPcfeKYL1';
$seedGenerator = new Bip39SeedGenerator();
$seed = $seedGenerator->getSeed($mnemonic);
$hdFactory = new HierarchicalKeyFactory();
$master = $hdFactory->fromEntropy($seed);
$hardened = $master->derivePath("44'/13107'/0'/0/0");
$pubKey = new PayToPubKeyHashAddress($hardened->getPublicKey()->getPubKeyHash());
$verifyAddress = $pubKey->getAddress();
if ($verifyAddress != $address) {
return $this->failed('非法操作');
}
$user = User::where('username', $address)->first();

View File

@@ -46,4 +46,17 @@ class UserController extends Controller
return $this->success($user->privacy);
}
public function download(): JsonResponse
{
return $this->success('https://www.uzchain.tech?invite='.Api::user()->username);
}
public function email()
{
}
public function mobile()
{
}
}