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
045dfe30
authored
Nov 01, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化接口
parent
0dc9b2db
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
8 deletions
.idea/workspace.xml
app/Http/Controllers/Api/AuthApiController.php
app/Models/User.php
config/database.php
.idea/workspace.xml
View file @
045dfe30
...
...
@@ -4,7 +4,8 @@
<list
default=
"true"
id=
"fb90add0-1393-48c2-9f26-72365d42cd03"
name=
"变更"
comment=
""
>
<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$/routes/api.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/routes/api.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app/Models/User.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app/Models/User.php"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/config/database.php"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/config/database.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"
/>
...
...
@@ -183,7 +184,7 @@
<updated>
1666170258203
</updated>
<workItem
from=
"1666170260162"
duration=
"17108000"
/>
<workItem
from=
"1666835076791"
duration=
"693000"
/>
<workItem
from=
"1667266026118"
duration=
"1
0293
000"
/>
<workItem
from=
"1667266026118"
duration=
"1
2368
000"
/>
</task>
<servers
/>
</component>
...
...
app/Http/Controllers/Api/AuthApiController.php
View file @
045dfe30
...
...
@@ -20,9 +20,13 @@ class AuthApiController extends Controller
public
function
register
(
Request
$request
)
{
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'name'
=>
[
'required'
,
'string'
,
'max:255'
],
'email'
=>
[
'required'
,
'string'
,
'email'
,
'max:255'
,
'unique:users'
],
'password'
=>
[
'required'
,
'string'
,
'min:8'
,
'confirmed'
],
'email'
=>
'required|string|email|max:255|unique:users'
,
'password'
=>
'required|string|min:8|confirmed'
,
'first_name'
=>
'required|max:100'
,
'last_name'
=>
'required|max:100'
,
'email_code'
=>
'required|max:100'
,
'phone'
=>
'required|max:100'
,
'company_name'
=>
'required|max:100'
,
],
[
'password.confirmed'
=>
'Passwords do not match!'
,
]);
...
...
@@ -30,6 +34,12 @@ class AuthApiController extends Controller
return
$this
->
setError
(
$validator
->
errors
()
->
first
());
}
//判断邮箱验证码
$redisKey
=
'sem_email_code_register_'
.
$request
->
input
(
'email'
);
$cachedEmailCode
=
Redis
::
get
(
$redisKey
);
if
(
$cachedEmailCode
!=
$request
->
input
(
'email_code'
))
{
return
$this
->
setError
(
'Email code invalid'
);
}
$user
=
User
::
createUser
(
$request
->
all
());
\Auth
::
login
(
$user
);
...
...
app/Models/User.php
View file @
045dfe30
...
...
@@ -46,8 +46,11 @@ class User extends Authenticatable implements MustVerifyEmail
public
static
function
createUser
(
$data
)
{
return
User
::
create
([
'name'
=>
$data
[
'name'
],
'email'
=>
$data
[
'email'
],
'first_name'
=>
$data
[
'first_name'
],
'last_name'
=>
$data
[
'last_name'
],
'phone'
=>
$data
[
'phone'
],
'email_verified_at'
=>
now
(),
'company_name'
=>
$data
[
'company_name'
],
'password'
=>
Hash
::
make
(
$data
[
'password'
]),
]);
}
...
...
config/database.php
View file @
045dfe30
...
...
@@ -123,7 +123,7 @@ return [
'options'
=>
[
'cluster'
=>
env
(
'REDIS_CLUSTER'
,
'redis'
),
'prefix'
=>
env
(
'REDIS_PREFIX'
,
Str
::
slug
(
env
(
'APP_NAME'
,
'laravel'
),
'_'
)
.
'_database_
'
),
'prefix'
=>
env
(
'REDIS_PREFIX'
,
'
'
),
],
'default'
=>
[
...
...
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