Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,18 @@ class SessionsController < Devise::SessionsController
def respond_with(_resource, _options = {})
render json: {
status: { code: 200, message: 'User signed in successfully',
data: { user: UserSerializer.new(current_user).serializable_hash[:data][:attributes] } }
data: { user: UserSerializer.new(current_user).serializable_hash.dig(:data, :attributes) } }
}, status: :ok
end

def respond_to_on_destroy
if request.headers['Authorization'].present?
jwt_payload = JWT.decode(request.headers['Authorization'].split.last,
Rails.application.credentials.fetch(:secret_key_base)).first
current_user = User.find(jwt_payload['sub'])
end

if current_user
render json: {
status: 200,
message: 'Logged out successfully.'
}, status: :ok
else
render json: {
status: 401,
message: "Couldn't find an active session."
}, status: :unauthorized
current_user.update(jti: SecureRandom.uuid)
end
render json: {
status: 200,
message: 'Logged out successfully (or already logged out).'
}, status: :ok
end
end
end
3 changes: 3 additions & 0 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@
font-size: 0.75rem;
margin-top: 0.25rem;
display: block;
display: inline-flex;
align-items: center;
gap: 0.25rem;
}

/* Cards */
Expand Down
61 changes: 0 additions & 61 deletions client/src/components/Login.js

This file was deleted.

91 changes: 0 additions & 91 deletions client/src/components/Signup.js

This file was deleted.

4 changes: 0 additions & 4 deletions client/src/components/auth/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const Login = () => {
if (isAuthenticated) navigate('/');
}, [isAuthenticated, navigate]);

useEffect(() => {
clearError();
}, [clearError]);

const onSubmit = async (data) => {
setIsSubmitting(true);
const result = await login(data);
Expand Down
12 changes: 7 additions & 5 deletions client/src/components/auth/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ const Signup = () => {
if (isAuthenticated) navigate('/');
}, [isAuthenticated, navigate]);

useEffect(() => {
clearError();
}, [clearError]);

const onSubmit = async (data) => {
setIsSubmitting(true);
const result = await registerUser({
Expand Down Expand Up @@ -116,7 +112,13 @@ const Signup = () => {
id="password"
{...register('password', {
required: 'Password is required',
minLength: { value: 6, message: 'Password must be at least 6 characters' }
minLength: {
value: 6,
message: 'Password must be at least 6 characters'
},
validate: value =>
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_\-+=\[\]{};:'",.<>?/`~\\|])[A-Za-z\d!@#$%^&*()_\-+=\[\]{};:'",.<>?/`~\\|]{6,}$/.test(value)
|| 'Password must contain at least 1 uppercase letter, 1 lowercase letter, 1 digit, and 1 special character'
})}
placeholder="Create a password"
autoComplete="new-password"
Expand Down
Loading
Loading