示例#1
0
int main()
{
	vector<Account*> accounts;
	string cmd;

	while(cmd !="quit")
	{
		cin>>cmd;
		if(cmd == "add")
		{
			string name, type;
			int amount;
			double interest_rate;

			cin>>name>>type>>amount>>interest_rate;

			Account* acc = CreateAccount(type, name, amount, interest_rate);

			if(acc == NULL)
			{
				cout<<"Error: "<<type<<", "<<name<<endl;
			}
			else
			{
				accounts.push_back(acc);
			}
		}
		else if(cmd == "delete")
示例#2
0
void CreateNewAccountAndCharacter(char *name,char *password)
{
	user_node *u;
	int account_id;
	
	if (ConfigBool(DEBUG_SMTP))
	{
		dprintf("name = %s\n",name);
		dprintf("password = %s\n",password);
	}
	
	if (CreateAccount(name,password,ACCOUNT_NORMAL,&account_id) == False)
	{
		lprintf("CreateNewAccountAndCharacter tried to create account %s which already exists\n",
			name);
		return;
	}
	u = CreateNewUser(account_id,USER_CLASS);
	if (u == NULL)
	{
		eprintf("CreateNewAccountAndCharacter can't find just created user for account %i!\n",
			account_id);
		return;
	}
	lprintf("Created account %i (%s), object %i\n",account_id,name,u->object_id);
}
示例#3
0
void startmenu::on_pushButton_clicked() //Login/account creation button
{
        QString Password, UsernameS;
        Username = ui->lineEdit->text();
        UsernameS = Username;
        UsernameS.resize(4);
        Password = ui->lineEdit_2->text();
        Password = UsernameS + Password;
        Password = QGrostlHash(Password).toHexString();
        if (!myDB.isOpen()){
                qDebug() << "Lost connection to db.";
                return;
        }
        QSqlQuery qry;
        if (Login && PasswordIsNotEmpty)
        {
                if (qry.exec("SELECT username, password FROM user WHERE username=\'" + Username
                        + "\' AND password=\'" + Password + "\'"))
                {
                        if (qry.next())
                        {
                                MainWindow *mainWin = new MainWindow();
                                mainWin->setWindowTitle("Secure Shield: " + Username + " logged in");
                                mainWin->show();
                                hide();
                        }
                        else {
                                ui->label_5->setText("[-] Incorrect Username or Password");
                        }
                }
        }
        if (Creation && PasswordIsNotEmpty)
        {
        QString PasswordV;
        UsernameS = Username;
        UsernameS.resize(4);
        PasswordV = ui->lineEdit_3->text();
        PasswordV = UsernameS + PasswordV;
        PasswordV = QGrostlHash(PasswordV).toHexString();

        if (!CheckUsername(Username) && Username != "")
                  {
            if (Password == PasswordV && Password != "")
                        {
                CreateAccount(Username, Password);
                QMessageBox::warning(this, "Success!", "Your account has been created!");
                MainWindow *mainWin = new MainWindow();
                mainWin->setWindowTitle("Secure Shield: " + Username + " logged in");
                mainWin->show();
                mainWin->showPasswords();
                hide();
                        }
        else {
                QMessageBox::warning(this, "ERROR", "The passwords do not match");
             }
                  }
        else {
                QMessageBox::warning(this, "ERROR", "This username is already in use");
             }
        }
}