Files
TripLog/templates/auth/login.php
T
laoyang d6a7cc99bc 登录支持用户名,与手机号并存 (#2)
原来 Auth::attempt 只按 phone_hash 查,用户名永远登不进去。
家人账号常常不填手机号,演示场景下用名字登录更自然。

- 先按手机号 hash 精确查(唯一),未命中再按 name 查
- 重名命中多条一律拒绝,绝不取第一条(否则 A 的密码能登进 B 的账号)
- 表单 label 改「手机号 / 用户名」,错误文案改「账号或密码错误」

验证:逻辑单测 10/10(含重名拒绝);反向验证改坏判断即变红 (#2)
2026-11-01 11:07:30 +08:00

19 lines
758 B
PHP

<div class="login-wrapper">
<form method="post" action="<?= url('auth/doLogin') ?>" class="login-form">
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
<h1>🏠 家庭出行记录</h1>
<p class="muted">请登录后继续</p>
<div class="form-row">
<label>手机号 / 用户名</label>
<input type="text" name="phone" required autofocus placeholder="手机号或用户名">
</div>
<div class="form-row">
<label>密码</label>
<input type="password" name="password" required placeholder="请输入密码">
</div>
<button type="submit" class="btn-primary" style="width:100%; padding:11px;">登录</button>
</form>
</div>