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
13 changes: 13 additions & 0 deletions app/src/pages/auth/CentreHeadSignup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BUILDINGS } from '../../constants/models';

export function CentreHeadSignup() {
const [formData, setFormData] = useState({
name: '',
email: '',
password: '',
phone_number: '',
Expand Down Expand Up @@ -97,6 +98,18 @@ export function CentreHeadSignup() {
<div>
<h2 className="text-xs font-bold uppercase tracking-widest text-[#666666] mb-4">Account Details</h2>
<div className="grid grid-cols-1 md:grid-cols-2 gap-5">
<div className="md:col-span-2">
<label className={labelCls}>Full Name</label>
<input
type="text"
name="name"
value={formData.name}
onChange={handleChange}
className={inputCls}
placeholder="Anita Sharma"
required
/>
</div>
<div>
<label className={labelCls}>Email Address</label>
<input
Expand Down
13 changes: 13 additions & 0 deletions app/src/pages/auth/WardenSignup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { HOSTELS } from '../../constants/models';

export function WardenSignup() {
const [formData, setFormData] = useState({
name: '',
email: '',
password: '',
phone_number: '',
Expand Down Expand Up @@ -97,6 +98,18 @@ export function WardenSignup() {
<div>
<h2 className="text-xs font-bold uppercase tracking-widest text-[#666666] mb-4">Account Details</h2>
<div className="grid grid-cols-1 md:grid-cols-2 gap-5">
<div className="md:col-span-2">
<label className={labelCls}>Full Name</label>
<input
type="text"
name="name"
value={formData.name}
onChange={handleChange}
className={inputCls}
placeholder="Rahul Kumar"
required
/>
</div>
<div>
<label className={labelCls}>Email Address</label>
<input
Expand Down
1 change: 1 addition & 0 deletions handlers/centrehead_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (h *AuthHandler) CentreheadSignup(c *gin.Context) {
inputs.Password = string(hashedPass)

centrehead := models.Centrehead{
Name: inputs.Name,
Email: inputs.Email,
Password: inputs.Password,
Building: inputs.Building,
Expand Down
1 change: 1 addition & 0 deletions handlers/warden_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (h *AuthHandler) WardenSignup (c *gin.Context) {
// send a email for account verification

warden := models.Warden{
Name: inputs.Name,
Email: inputs.Email,
Password: inputs.Password,
Hostel: inputs.Hostel,
Expand Down
2 changes: 2 additions & 0 deletions models/centrehead_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (

type Centrehead struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
Name string `gorm:"not null" json:"name"`
Email string `gorm:"uniqueIndex;not null" json:"email"`
Password string `gorm:"not null" json:"password"`
Building BuildingName `gorm:"type:varchar(100);not null" json:"building"`
Expand All @@ -39,6 +40,7 @@ type Centrehead struct {
}

type CentreheadSignup struct {
Name string `json:"name" binding:"required"`
Email string `json:"email" binding:"required"`
Password string `json:"password" binding:"required"`
Building BuildingName `json:"building" binding:"required"`
Expand Down
2 changes: 2 additions & 0 deletions models/warden_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (

type Warden struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
Name string `gorm:"not null" json:"name"`
Email string `gorm:"uniqueIndex;not null" json:"email"`
Password string `gorm:"not null" json:"password"`
Hostel HostelName `gorm:"type:varchar(30);not null" json:"hostel"`
Expand All @@ -33,6 +34,7 @@ type Warden struct {
}

type WardenSignup struct {
Name string `json:"name" binding:"required"`
Email string `json:"email" binding:"required"`
Password string `json:"password" binding:"required"`
Hostel HostelName `json:"hostel" binding:"required"`
Expand Down
1 change: 1 addition & 0 deletions test/centrehead_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestCentreheadSignup_AlreadyRegistered(t *testing.T) {

e := newAuthRouter(db, noAuth())
body := map[string]any{
"name": "Duplicate Head",
"email": "ch.dup@iit.ac.in",
"password": "whatever",
"building": string(models.LHC),
Expand Down
1 change: 1 addition & 0 deletions test/warden_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestWardenSignup_AlreadyRegistered(t *testing.T) {

e := newAuthRouter(db, noAuth())
body := map[string]any{
"name": "Duplicate Warden",
"email": "war.dup@iit.ac.in",
"password": "whatever",
"hostel": string(models.KBH),
Expand Down
Loading