fix: 因應資料庫欄位修改2

1. 使用Username作為primary key
2. Username, Email 皆可作為登入依據
This commit is contained in:
JingChiang 2024-09-12 21:19:51 +08:00
parent 5cf59af63e
commit 1fb3cfaa53

View File

@ -183,7 +183,7 @@ class _RegisterPageState extends State<RegisterPage> {
String password = _passwordController.text; String password = _passwordController.text;
var result = await conn.execute( var result = await conn.execute(
'SELECT * FROM HomeLogin WHERE homeEmail = :email OR homeName = :name', 'SELECT * FROM HomeLogin WHERE homeEmail = :email OR homeUserName = :name',
{'email': email, 'name': name}, {'email': email, 'name': name},
); );
@ -192,9 +192,8 @@ class _RegisterPageState extends State<RegisterPage> {
SnackBar(content: Text('註冊失敗:電子信箱或帳號名稱已被使用,請嘗試更換或登入')), SnackBar(content: Text('註冊失敗:電子信箱或帳號名稱已被使用,請嘗試更換或登入')),
); );
} else { } else {
// TODO: Phone Address is setting not null in database, remove it or setting default value
await conn.execute( await conn.execute(
'INSERT INTO HomeLogin (homeName, homeEmail, homePassword) VALUES (:name, :email, :password)', 'INSERT INTO HomeLogin (homeUserName, homeEmail, homePassword) VALUES (:name, :email, :password)',
{'name': name, 'email': email, 'password': password}, {'name': name, 'email': email, 'password': password},
); );
@ -269,8 +268,7 @@ class _RegisterPageState extends State<RegisterPage> {
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
prefixIcon: Icon(Icons.person_outlined), prefixIcon: Icon(Icons.person_outlined),
// TODO: user name in database setting as primary is not suitable change to username would better labelText: '使用者名稱',
labelText: '用戶姓名',
), ),
), ),
SizedBox(height: 20), SizedBox(height: 20),