Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Custom default password added
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkleen committed Mar 7, 2024
1 parent 0413ba4 commit ca95b8d
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ DEBUG="false"
ALLOWED_HOSTS="127.0.0.1, 0.0.0.0, *"
SERVER_PORT=2087

# DEFAULT_USER_PASSWORD="Gatekeeper2024@"

# SET_EMAIL="false"
# EMAIL_HOST="smtp.gmail.com"
# EMAIL_PORT=587
Expand Down
2 changes: 2 additions & 0 deletions GateKeeper/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

SERVER_PORT = os.environ.get('SERVER_PORT', '2087')

DEFAULT_USER_PASSWORD = os.environ.get('DEFAULT_USER_PASSWORD', 'Gatekeeper2024@')

AUTH_USER_MODEL = 'core.UserAccount'

# Email backend
Expand Down
3 changes: 2 additions & 1 deletion core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.forms import PasswordChangeForm
from core.models import UserAccount, Subscription, PanelConnection
from GateKeeper.settings import DEFAULT_USER_PASSWORD


class UserEmailChangeForm(forms.ModelForm):
Expand Down Expand Up @@ -151,7 +152,7 @@ def __init__(self, *args, **kwargs):

def save(self, commit=True):
user = super().save(commit=False)
user.set_password('Gatekeeper2024@') # Set a fixed password
user.set_password(DEFAULT_USER_PASSWORD) # Set a fixed password
if commit:
user.save()
return user
Expand Down
99 changes: 99 additions & 0 deletions core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Generated by Django 5.0.2 on 2024-03-07 11:08

import core.utils.utils
import django.contrib.auth.models
import django.core.validators
import django.db.models.deletion
import django.utils.timezone
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]

operations = [
migrations.CreateModel(
name='PanelConnection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('connection_name', models.CharField(max_length=64)),
('panel_name', models.CharField(choices=[('Marzban', 'Marzban'), ('x-ui alireza0', 'x-ui alireza0'), ('3x-ui MHSanaei', '3x-ui MHSanaei')], default='Marzban', max_length=32)),
('url', models.CharField(blank=True, max_length=64, null=True)),
('username', models.CharField(blank=True, max_length=128, null=True)),
('password', models.CharField(blank=True, max_length=256, null=True)),
('session_cookie', models.CharField(blank=True, max_length=1024, null=True)),
('is_active', models.BooleanField(default=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'ordering': ['-updated_at'],
},
),
migrations.CreateModel(
name='UserAccount',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('username', models.CharField(max_length=256, unique=True, validators=[django.core.validators.MaxLengthValidator(256)])),
('first_name', models.CharField(max_length=256, validators=[django.core.validators.MaxLengthValidator(256)])),
('last_name', models.CharField(max_length=256, validators=[django.core.validators.MaxLengthValidator(256)])),
('account_type', models.CharField(choices=[('user', 'user'), ('moderator', 'moderator'), ('admin', 'admin')], default='user', max_length=64)),
('is_active', models.BooleanField(default=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
],
options={
'ordering': ['-updated_at', '-created_at'],
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
migrations.CreateModel(
name='ResetPassword',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('key_token', models.CharField(default=core.utils.utils.generate_random_key, max_length=128, unique=True, validators=[django.core.validators.MaxLengthValidator(128)])),
('created_at', models.DateTimeField(auto_now_add=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='user', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created_at'],
},
),
migrations.CreateModel(
name='Subscription',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('subscription_uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
('subscription_title', models.CharField(max_length=512, null=True, validators=[django.core.validators.MaxLengthValidator(512)])),
('subscription_link', models.CharField(max_length=512, null=True, validators=[django.core.validators.MaxLengthValidator(512)])),
('use_count', models.IntegerField(default=0)),
('expose', models.BooleanField(default=False)),
('is_active', models.BooleanField(default=True)),
('user_email_in_xui_panel', models.CharField(max_length=512, null=True, validators=[django.core.validators.MaxLengthValidator(512)])),
('updated_at', models.DateTimeField(auto_now=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('assigned_to', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions_assignee', to=settings.AUTH_USER_MODEL)),
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions_creator', to=settings.AUTH_USER_MODEL)),
('panel_connection', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='panel', to='core.panelconnection')),
],
options={
'ordering': ['-updated_at', '-created_at'],
},
),
]

0 comments on commit ca95b8d

Please sign in to comment.