feat(api): add full signup/login flow with email & profile, ENV support, and port fix #18
					 2 changed files with 15 additions and 15 deletions
				
			
		| 
						 | 
					@ -8,6 +8,7 @@ class User(db.Model):
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    id = db.Column(db.Integer, primary_key=True)
 | 
					    id = db.Column(db.Integer, primary_key=True)
 | 
				
			||||||
    username = db.Column(db.String(80), unique=True, nullable=False)
 | 
					    username = db.Column(db.String(80), unique=True, nullable=False)
 | 
				
			||||||
 | 
					    email = db.Column(db.String(120), unique=True, nullable=False)  # Add email field
 | 
				
			||||||
    _password = db.Column("password", db.String(255), nullable=False)    
 | 
					    _password = db.Column("password", db.String(255), nullable=False)    
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    profile = db.relationship('UserProfile', back_populates='user', uselist=False, cascade="all, delete-orphan")
 | 
					    profile = db.relationship('UserProfile', back_populates='user', uselist=False, cascade="all, delete-orphan")
 | 
				
			||||||
| 
						 | 
					@ -29,11 +30,11 @@ class User(db.Model):
 | 
				
			||||||
@event.listens_for(User, 'after_insert')
 | 
					@event.listens_for(User, 'after_insert')
 | 
				
			||||||
def create_user_profile(mapper, connection, target):
 | 
					def create_user_profile(mapper, connection, target):
 | 
				
			||||||
    connection.execute(
 | 
					    connection.execute(
 | 
				
			||||||
        UserProfile.__table__.insert().values (
 | 
					        UserProfile.__table__.insert().values(
 | 
				
			||||||
            user_id = target.id,
 | 
					            user_id=target.id,
 | 
				
			||||||
            first_name = "",
 | 
					            first_name="",
 | 
				
			||||||
            last_name = "",
 | 
					            last_name="",
 | 
				
			||||||
            bio = "",
 | 
					            bio="",
 | 
				
			||||||
            profile_picture = ""
 | 
					            profile_picture=""
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
| 
						 | 
					@ -1,14 +1,13 @@
 | 
				
			||||||
from models import db
 | 
					from models import db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class UserProfile(db.Model):
 | 
					class UserProfile(db.Model):
 | 
				
			||||||
    __tablename__ = 'user_profile'
 | 
					    __tablename__ = 'user_profiles'
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    id = db.Column(db.Integer, primary_key = True)
 | 
					    id = db.Column(db.Integer, primary_key=True)
 | 
				
			||||||
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable = False)
 | 
					    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
 | 
				
			||||||
    first_name = db.Column(db.String(80), nullable = False)
 | 
					    first_name = db.Column(db.String(50), nullable=False, default="")
 | 
				
			||||||
    last_name = db.Column(db.String(80), nullable = False)
 | 
					    last_name = db.Column(db.String(50), nullable=False, default="")
 | 
				
			||||||
    bio = db.Column(db.Text, nullable = True)
 | 
					    bio = db.Column(db.Text, default="")
 | 
				
			||||||
    profile_picture = db.Column(db.String(255), nullable = True)
 | 
					    profile_picture = db.Column(db.String(255), default="")
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    user = db.relationship('User', back_populates='profile')
 | 
					    user = db.relationship('User', back_populates='profile')
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue