Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cookie userSession : { Email : string, Password : string }
- table user : {
- Id : int,
- Email : string,
- Password : string,
- FirstName : string,
- LastName : string
- }
- PRIMARY KEY Id
- table addresstype : {
- Id : int,
- DisplayName : string,
- Value : string
- }
- PRIMARY KEY Id
- table address : {
- Id : int,
- UserId : int,
- AddressTypeId : int,
- Address1 : string,
- Address2 : string,
- City : string,
- State : string,
- Zip : string,
- Country : string
- }
- PRIMARY KEY Id
- CONSTRAINT FK_User FOREIGN KEY (UserId) REFERENCES user(Id) ON DELETE CASCADE,
- CONSTRAINT FK_AddressType FOREIGN KEY (AddressTypeId) REFERENCES addresstype(Id) ON DELETE CASCADE
- sequence userSeq
- sequence addressSeq
- fun create (email, password, firstname, lastname) =
- let
- val cryptPass = Sha.hash password
- in
- id <- nextval userSeq;
- dml (INSERT INTO user (Id, Email,Password, FirstName, LastName)
- VALUES ({[id]},{[email]},{[cryptPass]},{[firstname]},{[lastname]})
- )
- end
- fun checkPassword (r:{Email:string, Password: string}) =
- let
- val cryptPass = {Email=r.Email, Password=Sha.hash r.Password}
- in
- re' <- oneOrNoRows1(SELECT user.Id
- FROM user
- WHERE user.Email = {[cryptPass.Email]}
- AND user.Password = {[cryptPass.Password]});
- case re' of
- None => return False
- | Some re => setCookie userSession { Value = cryptPass, Expires=None,Secure=False };
- return True
- end
- fun addAddress (userid, addresstypeid, address1, address2, city, state, zip, country) =
- id <- nextval addressSeq;
- dml (INSERT INTO address (Id, UserId, AddressTypeId, Address1, Address2, City, State, Zip, Country)
- VALUES ({[id]},{[userid]},{[addresstypeid]},{[address1]},{[address2]},{[city]}, {[state]}, {[zip]}, {[country]})
- )
- fun main () = return <xml>Test</xml>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement