Beispiel #1
0
static int
on_login(HWND window, int is_registering)
{
	char username[MAX_NAME_LENGTH+1];
	char password[BASE64_MD5_LENGTH+1];
	char confirm_password[128];
	char confirm_password_md5[BASE64_MD5_LENGTH+1];

	if (!GetDlgItemTextA(window, IDC_LOGIN_USERNAME, username, LENGTH(username))) {
		MessageBox(window, L"Enter a username less than "
				STRINGIFY(MAX_NAME_LENGTH) L" characters.",
				L"_username too long", MB_OK);
		return 1;
	}

	to_md5(password, GetDlgItemTextA2(window, IDC_LOGIN_PASSWORD));

	if (SendDlgItemMessage(window, IDC_LOGIN_SAVE, BM_GETCHECK, 0, 0)) {
		Settings_save_str("username", username);
		Settings_save_str("password", password);
	}
	g_settings.flags = (g_settings.flags & ~SETTING_AUTOCONNECT) | SETTING_AUTOCONNECT * SendDlgItemMessage(window, IDC_LOGIN_AUTOCONNECT, BM_GETCHECK, 0, 0);

	if (is_registering) {
		TasServer_send_login(username, password);
		return 0;

	}

retry:
	confirm_password[0] = 0;
	if (GetTextDialog2_create(window, "Confirm password", confirm_password,
		LENGTH(confirm_password)))
		return 1;

	to_md5(confirm_password_md5, confirm_password);
	if (strcmp(password, confirm_password_md5)) {
		MessageBox(window, L"_passwords do not match.", L"Can not register new account", 0);
		goto retry;
	}

	TasServer_send_register(username, password);
	return 0;
}
Beispiel #2
0
	void Person::change_password(const std::string &s) {
		std::string ss = to_md5(s);
		this->password(ss);
	}
Beispiel #3
0
	bool Person::check_password(const std::string &cpass) const {
		std::string s = to_md5(cpass);
		std::string s1 = this->password();
		return (s == s1);
	}