Example #1
0
		public static async Task<Account> Authenticate(Connection con)
		{
			await con.SendAsync("Please enter your username: (hit enter to register a new account)");
			var username = await con.ReadNextMsgAsync();

			Account account;
			if (username == "") {
				account = await Registrar.Register(con);;
			} else {
				var accounttask = Account.FromUsername(username);

				await con.SendAsync("Enter password: "******"Wrong password");
					return await Authenticate(con);
				}

			}
			return account;
		}
Example #2
0
		private static async Task<string> ReceiveValidPassword(Connection con)
		{
			await con.SendAsync("Enter your desired password: "******"Enter it again: ");
			var pw2 = await con.ReadNextMsgAsync();

			if (pw1 != pw2) {
				await con.SendAsync("Passwords don't match, try again ");
				return await ReceiveValidPassword(con);
			}

			return pw1;
		}
Example #3
0
		private static async Task<string> ReceiveValidUsername(Connection con)
		{
			await con.SendAsync("Please enter your desired username (a-Z, 0-9, _): ");
			var username = await con.ReadNextMsgAsync();

			if (await Account.IsUsernameTaken(username)) {
				await con.SendAsync("That name is already taken, please choose another one");
				return await ReceiveValidUsername(con);
			}

			return username;
		}