Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
O
Open-Platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杜宇森
Open-Platform
Commits
f0185086
Commit
f0185086
authored
Aug 31, 2021
by
UtopiaXC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚗
完成注册
parent
a1eecf4b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
17 deletions
+101
-17
UserController.php
app/Http/Controllers/UserController.php
+34
-2
UserProfile.php
app/Models/Users/UserProfile.php
+3
-0
constants.php
config/System/constants.php
+13
-0
2021_08_31_122512_create_users_profile.php
...ase/migrations/2021_08_31_122512_create_users_profile.php
+8
-8
login.blade.php
resources/views/login.blade.php
+42
-6
register.blade.php
resources/views/register.blade.php
+1
-1
No files found.
app/Http/Controllers/UserController.php
View file @
f0185086
...
@@ -3,7 +3,12 @@
...
@@ -3,7 +3,12 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Http\Utils\R
;
use
App\Http\Utils\R
;
use
App\Models\Users\User
;
use
App\Models\Users\UserProfile
;
use
Exception
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Webpatser\Uuid\Uuid
;
class
UserController
extends
Controller
class
UserController
extends
Controller
{
{
...
@@ -12,8 +17,35 @@ class UserController extends Controller
...
@@ -12,8 +17,35 @@ class UserController extends Controller
if
(
!
CaptchaController
::
check_captcha
(
$request
->
get
(
"captcha"
),
$request
->
cookie
(
app
()
->
getNamespace
()
.
"session"
)))
{
if
(
!
CaptchaController
::
check_captcha
(
$request
->
get
(
"captcha"
),
$request
->
cookie
(
app
()
->
getNamespace
()
.
"session"
)))
{
return
R
::
error
(
"403001"
,
"验证码错误"
);
return
R
::
error
(
"403001"
,
"验证码错误"
);
}
}
try
{
$email
=
$request
->
get
(
"email"
);
$user_name
=
$request
->
get
(
"user_name"
);
$password
=
password_hash
(
$request
->
get
(
"password"
),
PASSWORD_DEFAULT
);
$user
=
User
::
query
()
->
where
(
"user_name"
,
$user_name
)
->
orWhere
(
"user_name"
,
$email
)
->
get
();
if
(
sizeof
(
$user
)
!=
0
){
return
R
::
error
(
"403002"
,
"该邮箱或用户名已被注册"
);
}
$user
=
new
User
();
$user
->
id
=
Uuid
::
generate
();
$user
->
user_name
=
$user_name
;
$user
->
user_email
=
$email
;
$user
->
user_password
=
$password
;
$user
->
user_type
=
\UserTypeEnum
::
NORMAL
;
$user
->
user_status
=
\UserStatusEnum
::
NOT_VERITY
;
$user_profile
=
new
UserProfile
();
$user_profile
->
id
=
Uuid
::
generate
();
$user_profile
->
user_id
=
$user
->
id
;
DB
::
beginTransaction
();
$user
->
save
();
$user_profile
->
save
();
DB
::
commit
();
}
catch
(
Exception
$e
){
DB
::
rollBack
();
return
R
::
error
(
"500001"
,
"用户数据保存错误"
);
}
return
R
::
ok
();
return
R
::
ok
();
}
}
...
...
app/Models/Users/UserProfile.php
View file @
f0185086
...
@@ -8,4 +8,7 @@ use Illuminate\Database\Eloquent\Model;
...
@@ -8,4 +8,7 @@ use Illuminate\Database\Eloquent\Model;
class
UserProfile
extends
Model
class
UserProfile
extends
Model
{
{
use
HasFactory
;
use
HasFactory
;
protected
$table
=
"users_profile"
;
public
$incrementing
=
false
;
protected
$keyType
=
'string'
;
}
}
config/System/constants.php
View file @
f0185086
...
@@ -23,3 +23,16 @@ class Middleware
...
@@ -23,3 +23,16 @@ class Middleware
{
{
const
AUTH_MIDDLEWARE
=
'AuthMiddleWare'
;
const
AUTH_MIDDLEWARE
=
'AuthMiddleWare'
;
}
}
class
UserTypeEnum
{
const
ADMIN
=
"01"
;
const
NORMAL
=
"02"
;
const
VIP
=
"03"
;
}
class
UserStatusEnum
{
const
NOT_VERITY
=
"01"
;
const
NORMAL
=
"02"
;
const
BANNED
=
"03"
;
const
BANNED_FOREVER
=
"04"
;
}
database/migrations/2021_08_31_122512_create_users_profile.php
View file @
f0185086
...
@@ -16,14 +16,14 @@ class CreateUsersProfile extends Migration
...
@@ -16,14 +16,14 @@ class CreateUsersProfile extends Migration
Schema
::
create
(
'users_profile'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'users_profile'
,
function
(
Blueprint
$table
)
{
$table
->
uuid
(
'id'
);
$table
->
uuid
(
'id'
);
$table
->
string
(
'user_id'
);
$table
->
string
(
'user_id'
);
$table
->
string
(
'user_nickname'
);
$table
->
string
(
'user_nickname'
)
->
nullable
();
;
$table
->
string
(
'user_avatar'
);
$table
->
string
(
'user_avatar'
)
->
nullable
();
;
$table
->
string
(
'user_sex'
);
$table
->
string
(
'user_sex'
)
->
nullable
();
;
$table
->
date
(
'user_birthday'
);
$table
->
date
(
'user_birthday'
)
->
nullable
();
;
$table
->
string
(
'user_job'
);
$table
->
string
(
'user_job'
)
->
nullable
();
;
$table
->
string
(
'user_city'
);
$table
->
string
(
'user_city'
)
->
nullable
();
;
$table
->
string
(
'user_main_page'
);
$table
->
string
(
'user_main_page'
)
->
nullable
();
;
$table
->
string
(
'user_github'
);
$table
->
string
(
'user_github'
)
->
nullable
();
;
$table
->
timestamps
();
$table
->
timestamps
();
});
});
}
}
...
...
resources/views/login.blade.php
View file @
f0185086
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
<form>
<form>
<div class="
mb
-
3
">
<div class="
mb
-
3
">
<div class="
form
-
floating
">
<div class="
form
-
floating
">
<input type="
email
" class="
form
-
control
" id="
email
"
<input type="
text
" class="
form
-
control
" id="
email
"
placeholder="
name
@
example
.
com
">
placeholder="
邮箱或用户名
">
<label for="
email
">邮箱</label>
<label for="
email
">邮箱
或用户名
</label>
</div>
</div>
</div>
</div>
<div class="
mb
-
3
">
<div class="
mb
-
3
">
...
@@ -31,8 +31,8 @@
...
@@ -31,8 +31,8 @@
</div>
</div>
</div>
</div>
<div class="
d
-
grid
">
<div class="
d
-
grid
">
<button class="
btn
btn
-
info
m
-
b
-
xs
">登录</button>
<button
type="
button
" onclick="
doLogin
()
"
class="
btn
btn
-
info
m
-
b
-
xs
">登录</button>
<button
class="
btn
btn
-
primary
" onclick="
window
.
open
(
'{{WebUrl::FIND_PASSWORD}}'
)
">
<button
type="
button
" class="
btn
btn
-
primary
" onclick="
window
.
location
.
href
=
'{{WebUrl::FIND_PASSWORD}}'
">
找回密码
找回密码
</button>
</button>
</div>
</div>
...
@@ -45,13 +45,49 @@
...
@@ -45,13 +45,49 @@
</div>
</div>
</div>
</div>
</div>
</div>
<div class="
modal
fade
" id="
alert
" tabindex="
-
1
" aria-labelledby="
alert
" aria-hidden="
true
">
<div class="
modal
-
dialog
">
<div class="
modal
-
content
">
<div class="
modal
-
header
">
<h5 class="
modal
-
title
" id="
alert_title
"></h5>
<button type="
button
" class="
btn
-
close
" data-bs-dismiss="
modal
" aria-label="
Close
"></button>
</div>
<div class="
modal
-
body
" id="
alert_content
"></div>
<div class="
modal
-
footer
">
<button type="
button
" class="
btn
btn
-
primary
" data-bs-dismiss="
modal
">确认</button>
</div>
</div>
</div>
</div>
</body>
</body>
@endsection
@endsection
@section('script')
@section('script')
<script>
<script>
function logon(){
function doLogin(){
let email=$("
#email").val()
let
password
=
$
(
"#password"
)
.
val
()
if
(
email
===
""
||
password
===
""
){
showAlert
(
"警告"
,
"您有未输入的部分"
)
return
}
let
pattern
=
/^
\w
+
([
-+.
]
\w
+
)
*@
\w
+
([
-.
]
\w
+
)
*
\
.
\w
+
([
-.
]
\w
+
)
*
$
/
if
(
!
pattern
.
test
(
email
))
{
showAlert
(
"警告"
,
"邮箱格式错误"
)
return
}
$
.
ajax
({
})
}
}
function
showAlert
(
title
,
content
)
{
let
alert
=
$
(
"#alert"
)
let
title_elem
=
$
(
"#alert_title"
)
let
content_elem
=
$
(
"#alert_content"
)
title_elem
.
html
(
title
)
content_elem
.
html
(
content
)
alert
.
modal
(
'show'
)
}
</
script
>
</
script
>
@
endsection
@
endsection
resources/views/register.blade.php
View file @
f0185086
...
@@ -85,7 +85,7 @@
...
@@ -85,7 +85,7 @@
<div class="
modal
-
body
">请前往登录,并查看自己的邮箱进行激活(可能在垃圾邮件中)</div>
<div class="
modal
-
body
">请前往登录,并查看自己的邮箱进行激活(可能在垃圾邮件中)</div>
<div class="
modal
-
footer
">
<div class="
modal
-
footer
">
<button type="
button
" class="
btn
btn
-
primary
"
<button type="
button
" class="
btn
btn
-
primary
"
{{-- onclick="
window
.
location
.
href
=
'{{WebUrl::LOGIN}}'
" --}}
onclick="
window
.
location
.
href
=
'{{WebUrl::LOGIN}}'
"
data-bs-dismiss="
modal
">确认</button>
data-bs-dismiss="
modal
">确认</button>
</div>
</div>
</div>
</div>
...
...
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