Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
img-manager
Project
Overview
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
Ivan Lan
img-manager
Commits
f506fe2b
Commit
f506fe2b
authored
Mar 08, 2025
by
Ivan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix signup
parent
235928c3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
224 additions
and
3 deletions
+224
-3
users_controller.rb
app/controllers/users_controller.rb
+30
-0
New.jsx
app/frontend/pages/sessions/New.jsx
+2
-2
New.jsx
app/frontend/pages/users/New.jsx
+185
-0
20250308064523_add_name_to_users.rb
db/migrate/20250308064523_add_name_to_users.rb
+5
-0
schema.rb
db/schema.rb
+2
-1
No files found.
app/controllers/users_controller.rb
0 → 100644
View file @
f506fe2b
class
UsersController
<
ApplicationController
allow_unauthenticated_access
only:
%i[ new create ]
def
new
render
inertia:
"users/New"
,
props:
{
flash:
flash
.
to_h
}
end
def
create
@user
=
User
.
new
(
user_params
)
if
@user
.
save
# Automatically log in the user after registration
start_new_session_for
@user
redirect_to
after_authentication_url
,
notice:
"Welcome! Your account has been created successfully."
else
render
inertia:
"users/New"
,
props:
{
errors:
@user
.
errors
.
as_json
,
flash:
flash
.
to_h
}
end
end
private
def
user_params
params
.
require
(
:user
).
permit
(
:name
,
:email_address
,
:password
,
:password_confirmation
)
end
end
app/frontend/pages/sessions/New.jsx
View file @
f506fe2b
...
...
@@ -60,7 +60,7 @@ export default function SessionsNew({ flash }) {
</
Form
.
Control
>
{
errors
.
email_address
&&
(
<
Form
.
Message
className=
"text-sm text-red-600"
>
{
errors
.
email_address
}
{
Array
.
isArray
(
errors
.
email_address
)
?
errors
.
email_address
[
0
]
:
errors
.
email_address
}
</
Form
.
Message
>
)
}
</
Form
.
Field
>
...
...
@@ -83,7 +83,7 @@ export default function SessionsNew({ flash }) {
</
Form
.
Control
>
{
errors
.
password
&&
(
<
Form
.
Message
className=
"text-sm text-red-600"
>
{
errors
.
password
}
{
Array
.
isArray
(
errors
.
password
)
?
errors
.
password
[
0
]
:
errors
.
password
}
</
Form
.
Message
>
)
}
</
Form
.
Field
>
...
...
app/frontend/pages/users/New.jsx
0 → 100644
View file @
f506fe2b
import
{
useState
}
from
'react'
import
{
Head
,
Link
,
useForm
,
router
}
from
'@inertiajs/react'
import
*
as
Form
from
'@radix-ui/react-form'
import
ErrorMessage
from
'../../components/ErrorMessage'
export
default
function
UsersNew
({
flash
,
errors
=
{}
})
{
const
{
data
,
setData
,
processing
}
=
useForm
({
name
:
''
,
email_address
:
''
,
password
:
''
,
password_confirmation
:
''
,
})
const
handleSubmit
=
(
e
)
=>
{
e
.
preventDefault
()
router
.
post
(
'/users'
,
{
user
:
data
})
}
return
(
<
div
className=
"min-h-screen flex flex-col justify-center py-12 sm:px-6 lg:px-8 bg-gray-50"
>
<
Head
title=
"Sign up"
/>
<
div
className=
"sm:mx-auto sm:w-full sm:max-w-md"
>
<
h2
className=
"mt-6 text-center text-3xl font-extrabold text-gray-900"
>
Create a new account
</
h2
>
<
p
className=
"mt-2 text-center text-sm text-gray-600"
>
Or
{
' '
}
<
Link
href=
"/session/new"
className=
"font-medium text-indigo-600 hover:text-indigo-500"
>
log in to your account
</
Link
>
</
p
>
</
div
>
<
div
className=
"mt-8 sm:mx-auto sm:w-full sm:max-w-md"
>
<
div
className=
"bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10"
>
{
flash
?.
alert
&&
(
<
div
className=
"mb-4"
>
<
ErrorMessage
message=
{
flash
.
alert
}
/>
</
div
>
)
}
<
Form
.
Root
className=
"space-y-6"
onSubmit=
{
handleSubmit
}
>
<
Form
.
Field
name=
"name"
className=
"space-y-1"
>
<
Form
.
Label
className=
"block text-sm font-medium text-gray-700"
>
Full name
</
Form
.
Label
>
<
Form
.
Control
asChild
>
<
input
id=
"name"
name=
"name"
type=
"text"
autoComplete=
"name"
required
value=
{
data
.
name
}
onChange=
{
(
e
)
=>
setData
(
'name'
,
e
.
target
.
value
)
}
className=
"appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
/>
</
Form
.
Control
>
{
errors
.
name
&&
(
<
Form
.
Message
className=
"text-sm text-red-600"
>
{
errors
.
name
}
</
Form
.
Message
>
)
}
</
Form
.
Field
>
<
Form
.
Field
name=
"email_address"
className=
"space-y-1"
>
<
Form
.
Label
className=
"block text-sm font-medium text-gray-700"
>
Email address
</
Form
.
Label
>
<
Form
.
Control
asChild
>
<
input
id=
"email_address"
name=
"email_address"
type=
"email"
autoComplete=
"email"
required
value=
{
data
.
email_address
}
onChange=
{
(
e
)
=>
setData
(
'email_address'
,
e
.
target
.
value
)
}
className=
"appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
/>
</
Form
.
Control
>
{
errors
.
email_address
&&
(
<
Form
.
Message
className=
"text-sm text-red-600"
>
{
errors
.
email_address
}
</
Form
.
Message
>
)
}
</
Form
.
Field
>
<
Form
.
Field
name=
"password"
className=
"space-y-1"
>
<
Form
.
Label
className=
"block text-sm font-medium text-gray-700"
>
Password
</
Form
.
Label
>
<
Form
.
Control
asChild
>
<
input
id=
"password"
name=
"password"
type=
"password"
autoComplete=
"new-password"
required
value=
{
data
.
password
}
onChange=
{
(
e
)
=>
setData
(
'password'
,
e
.
target
.
value
)
}
className=
"appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
/>
</
Form
.
Control
>
{
errors
.
password
&&
(
<
Form
.
Message
className=
"text-sm text-red-600"
>
{
errors
.
password
}
</
Form
.
Message
>
)
}
</
Form
.
Field
>
<
Form
.
Field
name=
"password_confirmation"
className=
"space-y-1"
>
<
Form
.
Label
className=
"block text-sm font-medium text-gray-700"
>
Confirm password
</
Form
.
Label
>
<
Form
.
Control
asChild
>
<
input
id=
"password_confirmation"
name=
"password_confirmation"
type=
"password"
autoComplete=
"new-password"
required
value=
{
data
.
password_confirmation
}
onChange=
{
(
e
)
=>
setData
(
'password_confirmation'
,
e
.
target
.
value
)
}
className=
"appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
/>
</
Form
.
Control
>
{
errors
.
password_confirmation
&&
(
<
Form
.
Message
className=
"text-sm text-red-600"
>
{
errors
.
password_confirmation
}
</
Form
.
Message
>
)
}
</
Form
.
Field
>
<
div
>
<
Form
.
Submit
asChild
>
<
button
type=
"submit"
disabled=
{
processing
}
className=
"w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50"
>
{
processing
?
'Creating account...'
:
'Sign up'
}
</
button
>
</
Form
.
Submit
>
</
div
>
</
Form
.
Root
>
<
div
className=
"mt-6"
>
<
div
className=
"relative"
>
<
div
className=
"absolute inset-0 flex items-center"
>
<
div
className=
"w-full border-t border-gray-300"
/>
</
div
>
<
div
className=
"relative flex justify-center text-sm"
>
<
span
className=
"px-2 bg-white text-gray-500"
>
Or continue with
</
span
>
</
div
>
</
div
>
<
div
className=
"mt-6 grid grid-cols-1 gap-3"
>
<
button
type=
"button"
disabled
title=
"GitHub registration is not available yet"
className=
"w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-400 opacity-60 cursor-not-allowed"
>
<
svg
className=
"w-5 h-5 mr-2"
fill=
"currentColor"
viewBox=
"0 0 20 20"
aria
-
hidden=
"true"
>
<
path
fillRule=
"evenodd"
d=
"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z"
clipRule=
"evenodd"
/>
</
svg
>
<
span
>
GitHub
</
span
>
</
button
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
)
}
db/migrate/20250308064523_add_name_to_users.rb
0 → 100644
View file @
f506fe2b
class
AddNameToUsers
<
ActiveRecord
::
Migration
[
8.0
]
def
change
add_column
:users
,
:name
,
:string
end
end
db/schema.rb
View file @
f506fe2b
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
[
8.0
].
define
(
version:
2025_03_08_0
54000
)
do
ActiveRecord
::
Schema
[
8.0
].
define
(
version:
2025_03_08_0
64523
)
do
create_table
"image_tags"
,
force: :cascade
do
|
t
|
t
.
integer
"image_id"
,
null:
false
t
.
integer
"tag_id"
,
null:
false
...
...
@@ -49,6 +49,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_08_054000) do
t
.
string
"password_digest"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"name"
t
.
index
[
"email_address"
],
name:
"index_users_on_email_address"
,
unique:
true
end
...
...
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