File tree Expand file tree Collapse file tree 6 files changed +90
-16
lines changed Expand file tree Collapse file tree 6 files changed +90
-16
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,10 @@ export class AuthService {
1818
1919 apiBaseUrl = environment . apiBaseUrl ;
2020
21- public signup ( email : String , password : String ) : Observable < any > {
21+ public signup ( user ) : Observable < any > {
2222 return this . http . post (
2323 `${ this . apiBaseUrl } /users` ,
24- {
25- email : email ,
26- password : password
27- }
24+ user
2825 ) ;
2926 }
3027
Original file line number Diff line number Diff line change 33 < form #signupForm ="ngForm " (submit) ="signup() ">
44 < div class ="columns is-centered ">
55 < div class ="column is-6 ">
6+ < div class ="columns ">
7+ < div class ="column ">
8+ < div class ="field ">
9+ < p class ="control has-icons-left has-icons-right ">
10+ < input class ="input " type ="text " placeholder ="First Name " [(ngModel)] ="firstName " name ="firstname ">
11+ < span class ="icon is-small is-left ">
12+ < i class ="fas fa-users "> </ i >
13+ </ span >
14+ </ p >
15+ </ div >
16+ </ div >
17+ </ div >
18+ < div class ="columns ">
19+ < div class ="column ">
20+ < div class ="field ">
21+ < p class ="control has-icons-left has-icons-right ">
22+ < input class ="input " type ="text " placeholder ="Last Name " [(ngModel)] ="lastName " name ="lastname ">
23+ < span class ="icon is-small is-left ">
24+ < i class ="fas fa-users "> </ i >
25+ </ span >
26+ </ p >
27+ </ div >
28+ </ div >
29+ </ div >
30+ < div class ="columns ">
31+ < div class ="column ">
32+ < div class ="field ">
33+ < p class ="control has-icons-left has-icons-right ">
34+ < input class ="input " type ="number " placeholder ="Mobile number " [(ngModel)] ="mobileNumber " name ="mobileNumber ">
35+ < span class ="icon is-small is-left ">
36+ < i class ="fas fa-phone "> </ i >
37+ </ span >
38+ </ p >
39+ </ div >
40+ </ div >
41+ </ div >
42+ < div class ="columns ">
43+ < div class ="column ">
44+ < div class ="field ">
45+ < p class ="control has-icons-left has-icons-right ">
46+ < input class ="input " type ="number " placeholder ="Aadhar Number " [(ngModel)] ="aadharNumber " name ="aadharNumber ">
47+ < span class ="icon is-small is-left ">
48+ < i class ="fas fa-id-badge "> </ i >
49+ </ span >
50+ </ p >
51+ </ div >
52+ </ div >
53+ </ div >
654 < div class ="columns ">
755 < div class ="column ">
856 < div class ="field ">
Original file line number Diff line number Diff line change @@ -11,9 +11,22 @@ import { Router } from '@angular/router';
1111export class SignupComponent implements OnInit {
1212 email : string ;
1313 password : string ;
14+ firstName : string ;
15+ lastName : string ;
16+ mobileNumber : number ;
17+ aadharNumber : number ;
1418
1519 public signup ( ) {
16- this . authService . signup ( this . email , this . password )
20+ const user = {
21+ email : this . email ,
22+ password : this . password ,
23+ firstName : this . firstName ,
24+ lastName : this . lastName ,
25+ mobileNumber : + this . mobileNumber ,
26+ aadharNumber : + this . aadharNumber
27+ } ;
28+
29+ this . authService . signup ( user )
1730 . subscribe (
1831 ( res ) => {
1932 localStorage . setItem ( 'user' , JSON . stringify ( res [ 'user' ] ) ) ;
Original file line number Diff line number Diff line change @@ -11,11 +11,27 @@ const Schema = mongoose.Schema;
1111// });
1212
1313const userModel = new Schema ( {
14- email : { type : String , required : true } ,
14+ email : {
15+ type : String ,
16+ required : true
17+ } ,
1518 // first_name: { type: String, required: true },
1619 // last_name: { type: String, required: true },
17- password : { type : String , required : true } ,
18- shelter : { type : Schema . Types . ObjectId , ref : 'Shelter' } ,
19- shelterRequestLngLat : { type : String }
20+ password : {
21+ type : String ,
22+ required : true
23+ } ,
24+ shelter : {
25+ type : Schema . Types . ObjectId ,
26+ ref : 'Shelter'
27+ } ,
28+ shelterRequestLngLat : {
29+ type : String
30+ } ,
31+ firstName : { type : String } ,
32+ lastName : { type : String } ,
33+ mobileNumber : { type : Number } ,
34+ aadharNumber : { type : Number }
35+
2036} ) ;
2137module . exports = mongoose . model ( 'User' , userModel ) ;
Original file line number Diff line number Diff line change @@ -16,9 +16,8 @@ module.exports = {
1616 path : '/api/users' ,
1717 options : {
1818 handler : async ( request , h ) => {
19- let user = new User ( )
19+ let user = new User ( request . payload )
2020
21- user . email = request . payload . email
2221 user . password = await hashPasword ( request . payload . password )
2322
2423 await user . save ( console . error )
@@ -28,9 +27,6 @@ module.exports = {
2827 pre : [ {
2928 method : verifyUniqueUser
3029 } ] ,
31- validate : {
32- payload : createUserSchema
33- } ,
3430 description : 'User signup' ,
3531 notes : 'Returns a token on successful signup' ,
3632 tags : [ 'api' , 'user' ]
Original file line number Diff line number Diff line change @@ -2,7 +2,11 @@ const Joi = require('joi');
22
33const createUserSchema = Joi . object ( ) . keys ( {
44 email : Joi . string ( ) . email ( ) . required ( ) ,
5- password : Joi . string ( ) . max ( 30 ) . required ( )
5+ password : Joi . string ( ) . max ( 30 ) . required ( ) ,
6+ firstName : Joi . string ( ) . max ( 30 ) . required ( ) ,
7+ lastName : Joi . string ( ) . max ( 30 ) . required ( ) ,
8+ mobileNumber : Joi . number ( ) . max ( 12 ) . required ( ) ,
9+ aadharNumber : Joi . number ( ) . max ( 12 ) . required ( )
610} )
711
812module . exports = createUserSchema ;
You can’t perform that action at this time.
0 commit comments