Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.21;
- contract Users{
- struct user_profile {
- string surname;
- string name;
- uint id;
- string address_line1;
- string address_line2;
- string postcode;
- string email;
- string username;
- string password;
- }
- uint private number_of_users;
- mapping(uint => uint) private credits;
- mapping(string => user_profile) internal users;
- function GenerateID() constant returns(uint){
- //Will generate a random id number as uint.
- uint id = 1;
- return id;
- }
- function _Register(string _surname, string _name, string line1, string line2,
- string _postcode, string _email, string _username, string _password) internal returns(string) {
- user_profile storage user;
- user.surname = _surname;
- user.name = _name;
- user.id = GenerateID();
- user.address_line1 = line1;
- user.address_line2 = line2;
- user.postcode = _postcode;
- user.email = _email;
- user.username = _username;
- user.password = _password;
- users[user.username] = user;
- credits[user.id] = 0;
- number_of_users++;
- return user.username;
- }
- }
- contract App is Users{
- function Register(string _surname, string _name, string line1, string line2,
- string _postcode, string _email, string _username, string _password) public returns(bool success){
- string memory username = _Register(_surname, _name, line1, line2, _postcode, _email, _username, _password);
- //Check whether user registration successful.
- if(users[username].id > 0) return true;
- return false;
- }
- function Login(string username, string password) public returns(bool success){
- if(keccak256(password) == keccak256(users[username].password)) {
- //Go to vip area.
- return true;
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment