22 lines
986 B
TypeScript
22 lines
986 B
TypeScript
import type { AdminIssuedOneTimePassword } from '../api'
|
|
|
|
export interface GeneratedCredential {
|
|
owner: string
|
|
password: string
|
|
kind: 'initial' | 'one-time'
|
|
}
|
|
|
|
export function oneTimePasswordCredential(out: AdminIssuedOneTimePassword): GeneratedCredential {
|
|
return { owner: out.owner, password: out.oneTimePassword, kind: 'one-time' }
|
|
}
|
|
|
|
export function GeneratedCredentialPanel({ credential, onClose }: { credential: GeneratedCredential; onClose: () => void }) {
|
|
return <div className="ad-reset">
|
|
<p className="ad-hint">{credential.kind === 'initial'
|
|
? `初始密码仅显示一次,请立即安全交付给 ${credential.owner}。`
|
|
: `一次性登录密码仅显示一次,请立即安全交付给 ${credential.owner};使用后必须强制改密。`}</p>
|
|
<input className="lg-input ad-mono" readOnly value={credential.password} aria-label="一次性密码" />
|
|
<button type="button" className="ad-mini" onClick={onClose}>关闭</button>
|
|
</div>
|
|
}
|