Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0dc9b2db
authored
Nov 01, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
邮箱
parent
f432d22b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
15 deletions
.idea/workspace.xml
app/Http/Controllers/Api/AuthApiController.php
routes/api.php
.idea/workspace.xml
View file @
0dc9b2db
...
...
@@ -2,14 +2,9 @@
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"fb90add0-1393-48c2-9f26-72365d42cd03"
name=
"变更"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.env"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.env"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Controllers/Api/AuthApiController.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Controllers/Api/AuthApiController.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Controllers/Controller.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Controllers/Controller.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Http/Kernel.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Http/Kernel.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/config/database.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/config/database.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/routes/api.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/routes/api.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/routes/web.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/routes/web.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/storage/app/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/storage/app/.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/storage/app/public/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/storage/app/public/.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/storage/framework/.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/storage/framework/.gitignore"
afterDir=
"false"
/>
...
...
@@ -188,7 +183,7 @@
<updated>
1666170258203
</updated>
<workItem
from=
"1666170260162"
duration=
"17108000"
/>
<workItem
from=
"1666835076791"
duration=
"693000"
/>
<workItem
from=
"1667266026118"
duration=
"
8640
000"
/>
<workItem
from=
"1667266026118"
duration=
"
10293
000"
/>
</task>
<servers
/>
</component>
...
...
app/Http/Controllers/Api/AuthApiController.php
View file @
0dc9b2db
...
...
@@ -73,6 +73,7 @@ class AuthApiController extends Controller
public
function
resetPassword
(
Request
$request
)
{
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'old_password'
=>
'required|min:8'
,
'password'
=>
[
'required'
,
'string'
,
'min:8'
,
'confirmed'
],
...
...
@@ -85,15 +86,15 @@ class AuthApiController extends Controller
if
(
$validator
->
fails
())
{
return
$this
->
setError
(
$validator
->
errors
()
->
first
());
}
$password
=
$request
->
get
(
'password'
);
$match
=
User
::
where
(
'password'
,
Hash
::
make
(
$request
->
get
(
'old_password'
)))
->
exists
();
if
(
!
$match
)
{
$oldPassword
=
$request
->
get
(
'old_password'
);
$userId
=
Auth
::
user
()
->
id
;
$hashedPassword
=
User
::
where
(
'id'
,
$userId
)
->
value
(
'password'
);
if
(
!
Hash
::
check
(
$oldPassword
,
$hashedPassword
))
{
return
$this
->
setError
(
'Wrong Password!'
);
}
$user
=
new
User
(
);
$user
=
User
::
find
(
$userId
);
$user
->
password
=
Hash
::
make
(
$password
);
$user
->
update_time
=
time
();
$result
=
$user
->
save
();
...
...
@@ -113,14 +114,14 @@ class AuthApiController extends Controller
return
$this
->
setError
(
'Email address required'
);
}
$info
=
User
::
where
(
'email'
,
$email
)
->
first
();
if
(
$info
)
{
if
(
$info
&&
$type
==
'register'
)
{
return
$this
->
setError
(
'This email had been registered'
);
}
//发送验证码
$code
=
mt_rand
(
1000
,
9999
);
$redisKey
=
'sem_email_code_'
.
$type
;
Redis
::
h
set
(
$redisKey
,
$code
);
$redisKey
=
'sem_email_code_'
.
$type
.
'_'
.
$email
;
Redis
::
set
(
$redisKey
,
$code
);
Redis
::
expire
(
$redisKey
,
60
);
$subject
=
config
(
'mail.from.name'
);
$msg
=
'Email Code:'
.
$code
.
'.'
;
...
...
routes/api.php
View file @
0dc9b2db
...
...
@@ -22,8 +22,9 @@ Route::middleware(['api'])->namespace('Api')->group(function () {
Route
::
middleware
([
'api'
,
'api.check'
])
->
namespace
(
'Api'
)
->
group
(
function
()
{
Route
::
GET
(
'/user/logout'
,
'AuthApiController@logout'
);
Route
::
Any
(
'user/reset_password'
,
'AuthApiController@resetPassword'
);
Route
::
Any
(
'user/send_email_code'
,
'AuthApiController@sendEmailCode'
);
});
Route
::
middleware
([
'api'
,
'api.check'
])
->
namespace
(
'Auth'
)
->
group
(
function
()
{
Route
::
Any
(
'user/reset_password'
,
'ResetPasswordController@reset'
);
});
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