enhance: Display TOTP Register URL
Close #7261 Co-Authored-By: tamaina <tamaina@hotmail.co.jp>
This commit is contained in:
		
							parent
							
								
									e161b71651
								
							
						
					
					
						commit
						98e42ec6ff
					
				
					 3 changed files with 9 additions and 5 deletions
				
			
		|  | @ -1157,6 +1157,7 @@ _2fa: | ||||||
|   registerKey: "キーを登録" |   registerKey: "キーを登録" | ||||||
|   step1: "まず、{a}や{b}などの認証アプリをお使いのデバイスにインストールします。" |   step1: "まず、{a}や{b}などの認証アプリをお使いのデバイスにインストールします。" | ||||||
|   step2: "次に、表示されているQRコードをアプリでスキャンします。" |   step2: "次に、表示されているQRコードをアプリでスキャンします。" | ||||||
|  |   step2Url: "デスクトップアプリでは次のURLを入力します:" | ||||||
|   step3: "アプリに表示されているトークンを入力して完了です。" |   step3: "アプリに表示されているトークンを入力して完了です。" | ||||||
|   step4: "これからログインするときも、同じようにトークンを入力します。" |   step4: "これからログインするときも、同じようにトークンを入力します。" | ||||||
|   securityKeyInfo: "FIDO2をサポートするハードウェアセキュリティキーもしくは端末の指紋認証やPINを使用してログインするように設定できます。" |   securityKeyInfo: "FIDO2をサポートするハードウェアセキュリティキーもしくは端末の指紋認証やPINを使用してログインするように設定できます。" | ||||||
|  |  | ||||||
|  | @ -2,8 +2,8 @@ import bcrypt from 'bcryptjs'; | ||||||
| import * as speakeasy from 'speakeasy'; | import * as speakeasy from 'speakeasy'; | ||||||
| import * as QRCode from 'qrcode'; | import * as QRCode from 'qrcode'; | ||||||
| import config from '@/config/index.js'; | import config from '@/config/index.js'; | ||||||
| import define from '../../../define.js'; |  | ||||||
| import { UserProfiles } from '@/models/index.js'; | import { UserProfiles } from '@/models/index.js'; | ||||||
|  | import define from '../../../define.js'; | ||||||
| 
 | 
 | ||||||
| export const meta = { | export const meta = { | ||||||
| 	requireCredential: true, | 	requireCredential: true, | ||||||
|  | @ -40,15 +40,17 @@ export default define(meta, paramDef, async (ps, user) => { | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	// Get the data URL of the authenticator URL
 | 	// Get the data URL of the authenticator URL
 | ||||||
| 	const dataUrl = await QRCode.toDataURL(speakeasy.otpauthURL({ | 	const url = speakeasy.otpauthURL({ | ||||||
| 		secret: secret.base32, | 		secret: secret.base32, | ||||||
| 		encoding: 'base32', | 		encoding: 'base32', | ||||||
| 		label: user.username, | 		label: user.username, | ||||||
| 		issuer: config.host, | 		issuer: config.host, | ||||||
| 	})); | 	}); | ||||||
|  | 	const dataUrl = await QRCode.toDataURL(url); | ||||||
| 
 | 
 | ||||||
| 	return { | 	return { | ||||||
| 		qr: dataUrl, | 		qr: dataUrl, | ||||||
|  | 		url, | ||||||
| 		secret: secret.base32, | 		secret: secret.base32, | ||||||
| 		label: user.username, | 		label: user.username, | ||||||
| 		issuer: config.host, | 		issuer: config.host, | ||||||
|  |  | ||||||
|  | @ -52,8 +52,9 @@ | ||||||
| 					</template> | 					</template> | ||||||
| 				</I18n> | 				</I18n> | ||||||
| 			</li> | 			</li> | ||||||
| 			<li>{{ i18n.ts._2fa.step2 }}<br><img :src="twoFactorData.qr"></li> | 			<li>{{ i18n.ts._2fa.step2 }}<br><img :src="twoFactorData.qr"><p>{{ $ts._2fa.step2Url }}<br>{{ data.url }}</p></li> | ||||||
| 			<li>{{ i18n.ts._2fa.step3 }}<br> | 			<li> | ||||||
|  | 				{{ i18n.ts._2fa.step3 }}<br> | ||||||
| 				<MkInput v-model="token" type="text" pattern="^[0-9]{6}$" autocomplete="off" spellcheck="false"><template #label>{{ i18n.ts.token }}</template></MkInput> | 				<MkInput v-model="token" type="text" pattern="^[0-9]{6}$" autocomplete="off" spellcheck="false"><template #label>{{ i18n.ts.token }}</template></MkInput> | ||||||
| 				<MkButton primary @click="submit">{{ i18n.ts.done }}</MkButton> | 				<MkButton primary @click="submit">{{ i18n.ts.done }}</MkButton> | ||||||
| 			</li> | 			</li> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue