Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1dfa18ab
authored
Jul 09, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: email login
parent
13ea5cac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
6 deletions
+2
-6
model/user.go
+2
-6
No files found.
model/user.go
View file @
1dfa18ab
...
@@ -295,15 +295,11 @@ func (user *User) ValidateAndFill() (err error) {
...
@@ -295,15 +295,11 @@ func (user *User) ValidateAndFill() (err error) {
// that means if your field’s value is 0, '', false or other zero values,
// that means if your field’s value is 0, '', false or other zero values,
// it won’t be used to build query conditions
// it won’t be used to build query conditions
password
:=
user
.
Password
password
:=
user
.
Password
if
(
user
.
Username
==
""
&&
user
.
Email
==
""
)
||
password
==
""
{
if
user
.
Username
==
""
||
password
==
""
{
return
errors
.
New
(
"用户名或密码为空"
)
return
errors
.
New
(
"用户名或密码为空"
)
}
}
// find buy username or email
// find buy username or email
if
user
.
Username
!=
""
{
DB
.
Where
(
"username = ? OR email = ?"
,
user
.
Username
,
user
.
Username
)
.
First
(
user
)
DB
.
Where
(
User
{
Username
:
user
.
Username
})
.
First
(
user
)
}
else
if
user
.
Email
!=
""
{
DB
.
Where
(
User
{
Email
:
user
.
Email
})
.
First
(
user
)
}
okay
:=
common
.
ValidatePasswordAndHash
(
password
,
user
.
Password
)
okay
:=
common
.
ValidatePasswordAndHash
(
password
,
user
.
Password
)
if
!
okay
||
user
.
Status
!=
common
.
UserStatusEnabled
{
if
!
okay
||
user
.
Status
!=
common
.
UserStatusEnabled
{
return
errors
.
New
(
"用户名或密码错误,或用户已被封禁"
)
return
errors
.
New
(
"用户名或密码错误,或用户已被封禁"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment