Skip to content

Commit

Permalink
Merge pull request #584 from VitNode/refactor/remove_remember_password
Browse files Browse the repository at this point in the history
refactor: Remove "Remember me" button in sign in page and make it default
  • Loading branch information
aXenDeveloper authored Nov 25, 2024
2 parents 8757ea8 + 0c9e182 commit d918e0f
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 33 deletions.
4 changes: 0 additions & 4 deletions apps/frontend/src/plugins/core/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,6 @@
"sign_up": "Sign Up",
"email": "Email",
"password": "Password",
"remember": {
"label": "Remember me",
"desc": "Not recommended on shared computers."
},
"submit": "Log In",
"sso_first_login": {
"title": "Almost there!",
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ const config = () => {
secure: frontend_url.protocol === 'https:',
lang: 'NEXT_LOCALE',
login_token: {
expiresIn: 3, // 3 days
expiresInRemember: 90, // 90 days
expiresIn: 90, // 90 days
name: 'vitnode-login-token',
user_id: 'vitnode-user-id',
admin: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { core_admin_sessions } from '@/database/schema/admins';
import { core_sessions } from '@/database/schema/sessions';
import { DeviceAuthService } from '@/helpers/auth/device.service';
import { getConfigFile } from '@/helpers/config';
import { EmailHelperService } from '@/helpers/email/email.service';
import { InternalDatabaseService } from '@/utils/database/internal_database.service';
import { ForbiddenException, Injectable } from '@nestjs/common';
Expand All @@ -27,7 +26,7 @@ export class HelperSignInAuthService {
async createSession({
req,
res,
body: { email, remember, admin, user_id, name },
body: { email, admin, user_id, name },
}: {
body: { name: string; user_id: number } & Omit<SignInAuthBody, 'password'>;
req: Request;
Expand Down Expand Up @@ -57,7 +56,7 @@ export class HelperSignInAuthService {
);

const expiresValue: number = this.configService.getOrThrow(
`cookies.login_token.${remember ? 'expiresInRemember' : 'expiresIn'}`,
'cookies.login_token.expiresIn',
);

if (admin) {
Expand Down Expand Up @@ -168,7 +167,7 @@ export class HelperSignInAuthService {
secure: !!this.configService.getOrThrow('cookies.secure'),
domain: this.configService.getOrThrow('cookies.domain'),
path: '/',
expires: remember ? expires_at : undefined,
expires: expires_at,
sameSite: this.configService.getOrThrow('cookies.secure')
? 'none'
: 'lax',
Expand All @@ -182,7 +181,7 @@ export class HelperSignInAuthService {
secure: !!this.configService.getOrThrow('cookies.secure'),
domain: this.configService.getOrThrow('cookies.domain'),
path: '/',
expires: remember ? expires_at : undefined,
expires: expires_at,
sameSite: this.configService.getOrThrow('cookies.secure')
? 'none'
: 'lax',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export class CallbackSSOAuthService {
email: sso.user.email,
user_id: sso.user.id,
name: sso.user.name,
remember: true,
},
});

Expand Down Expand Up @@ -126,7 +125,6 @@ export class CallbackSSOAuthService {
email: user.email,
user_id: user.id,
name: user.name,
remember: true,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class RegisterCallbackSSOAuthService {
email: createUser.email,
user_id: createUser.id,
name: createUser.name,
remember: true,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { StringLanguage } from 'vitnode-shared/string-language.dto';
interface ComboBoxButtonProps<T extends FieldValues>
extends Omit<React.ComponentProps<typeof Button>, 'ariaLabel' | 'children'> {
field: ControllerRenderProps<T>;
label?: string;
label?: React.ReactNode | string;
labels?: Record<string, React.JSX.Element | string>;
multiple?: boolean;
placeholder?: string;
Expand Down Expand Up @@ -84,7 +84,7 @@ export function ComboBoxButton<T extends FieldValues>({

return (
<Button
ariaLabel={label ?? ''}
ariaLabel={typeof label === 'string' ? label : ''}
className={cn('w-full justify-start font-normal', className)}
role="combobox"
variant="outline"
Expand Down
11 changes: 0 additions & 11 deletions packages/frontend/src/views/theme/views/auth/sign/in/form.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import { AutoForm } from '@/components/form/auto-form';
import { AutoFormCheckbox as AutoFormCheckboxFromProps } from '@/components/form/fields/checkbox';
import { AutoFormInput } from '@/components/form/fields/input';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Button } from '@/components/ui/button';
Expand Down Expand Up @@ -68,16 +67,6 @@ export const FormSignIn = () => {
/>
),
},
{
id: 'remember',
label: t('remember.label'),
description: t('remember.desc'),
component: function AutoFormCheckbox(props) {
return (
<AutoFormCheckboxFromProps {...props} className="bg-card" />
);
},
},
]}
formSchema={formSchema}
onSubmit={onSubmit}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const useSignInView = () => {
const formSchema = z.object({
email: z.string().email().default(''),
password: z.string().min(1).default(''),
remember: z.boolean().default(false).optional(),
});

const onSubmit = async (values: z.infer<typeof formSchema>) => {
Expand Down
5 changes: 0 additions & 5 deletions packages/shared/src/auth/auth.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ export class SignInAuthBody {
@ApiProperty({ example: 'Test123!' })
@IsString()
password: string;

@ApiPropertyOptional({ example: false })
@IsBoolean()
@IsOptional()
remember?: boolean;
}

export class SignInAuthObj extends SignAuthObj {
Expand Down

0 comments on commit d918e0f

Please sign in to comment.