Ejemplo n.º 1
0
int main(void) 
{ 
	TERMIO_Init(); 
	printf("\n\r In test harness of passwords\r\n");
	/* Intializes random number generator */
  srand(rand());
	randomizePasswords();
	printPassword(getPassword(1));
	printPassword(getPassword(2));
	printPassword(getPassword(3));
	printPassword(getPassword(4));
	printf("\r\nThe correct password is %d\r\n\r\n", correctPassword);
	if (checkPassword(getPassword(1)))
		printf("Password1 is correct\r\n");
	else
		printf("Password1 is incorrect\r\n");
	if (checkPassword(getPassword(2)))
		printf("Password2 is correct\r\n");
	else
		printf("Password2 is incorrect\r\n");
	if (checkPassword(getPassword(3)))
		printf("Password3 is correct\r\n");
	else
		printf("Password3 is incorrect\r\n");
	if (checkPassword(getPassword(4)))
		printf("Password4 is correct\r\n");
	else
		printf("Password4 is incorrect\r\n");
		
	// Int to Character Stuff
	char c[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
	for (int i = 0; i < 5; i++) {
		printf("%c\r\n", c[getPassword(1)[i]]);
	}
}
Ejemplo n.º 2
0
void ESP8266WebServerEx::handleLogin(const char* login, size_t loginLength, const char* homePath) {
  
  hasLogin = true;
  
  String session = GetSessionId();
  long tag = -1;
  bool validSession = false;

  if ( session.length()==32 ) validSession = g_Session.isValid(session,&tag);

  // if everything is OK and user already logged in
  if ( validSession && tag>=0 && tag<10 ) {
    redirect(homePath);
    return;
  }

  // if user never login before, just display a form with challenge string
  long challenge = random(11,0x7fffffff);
  if ( !hasArg("userid") || !hasArg("hashpw") ) {
    challengeString = createChallengeString(challenge);
    SetSessionId(g_Session.Create(challenge));
    sendEx(200, "text/html", login, loginLength, &loginForm);
    return;
  }  

  // user already provided userId and password
  String userId = arg("userid");
  String hashPw = arg("hashpw");

  challengeString = createChallengeString(tag);
  if ( userId==adminUser ) {
    if ( checkPassword(adminUser,g_ModuleSettings.GetLoginPassword(true).c_str(),challengeString,hashPw) ) {
      g_Session.SetTag(session,ADMIN_USER_ID);
      redirect(homePath);
      return;  
    }
  } else if ( userId==normalUser) {
    if ( checkPassword(normalUser,g_ModuleSettings.GetLoginPassword(false).c_str(),challengeString,hashPw) ) {
      g_Session.SetTag(session,USER_USER_ID);
      redirect(homePath);
      return;
    }
  }

  // show the login form with invalid userid/password here
  challengeString = createChallengeString(challenge);
  SetSessionId(g_Session.Create(challenge));
  sendEx(200, "text/html", login, loginLength, &loginFormWithError);
}
Ejemplo n.º 3
0
static int
handlerBuyIngredient(void *packetPtr, size_t packetSize)
{
  int			i;
  char			*ingredientName;
  int			amount;
  char			log[128];
  char			*password = NULL;

  password = getStr(&packetPtr, &packetSize);
  if (checkPassword(password) == ADMIN) {
    ingredientName = getStr(&packetPtr, &packetSize);
    amount = getNumber(&packetPtr, &packetSize);

    if ((money - 2 * amount) < 0) {
      sendLogMessage("Need more money !!\n");
      return -1;
    }

    for (i = 0; stock[i].name != NULL; ++i) {
      if (!strcmp(ingredientName, stock[i].name)) {
	money -= 2 * amount;
	stock[i].quantity += amount;
	sendLogMessage(INGREDIENT_BOUGHT);
	sprintf(log, "echo \"%s was bought\" >> log", ingredientName);
	free(ingredientName);
	system(log);
	return amount;
      }
    }

    sendLogMessage(UNKNOWN_INGREDIENT);
  }
  return -1;
}
Ejemplo n.º 4
0
void goto_on_if_password(){
	if(checkPassword()) {
		next_alarmState = wait_on;
		set_lcd("wait_on", "");
		wait_on_timer.reset();
	}	
}
Ejemplo n.º 5
0
bool KNewPasswordDialog::checkAndGetPassword(QString *pwd)
{
    pwd->clear();

    if (d->ui.pwdWidget->passwordStatus() == KNewPasswordWidget::WeakPassword) {
        QMessageBox::StandardButton selectedButton = QMessageBox::warning(this,
                tr("Low Password Strength"),
                tr("The password you have entered has a low strength. "
                   "To improve the strength of "
                   "the password, try:\n"
                   " - using a longer password;\n"
                   " - using a mixture of upper- and lower-case letters;\n"
                   " - using numbers or symbols as well as letters.\n"
                   "\n"
                   "Would you like to use this password anyway?"),
                QMessageBox::Yes | QMessageBox::No);

        if (selectedButton == QMessageBox::No) {
            return false;
        }
    }
    if (!checkPassword(d->ui.pwdWidget->password())) {
        return false;
    }

    *pwd = d->ui.pwdWidget->password();
    return true;
}
Ejemplo n.º 6
0
void K3PasswordDialog::accept()
{
    if (m_Type == NewPassword) {
	if (strcmp(m_pEdit->password(), m_pEdit2->password())) {
	    KMessageBox::sorry(this, i18n("You entered two different "
		    "passwords. Please try again."));
	    erase();
	    return;
	}
	if (d->m_strengthBar && d->m_strengthBar->value() < d->passwordStrengthWarningLevel) {
	    int retVal = KMessageBox::warningContinueCancel(this,
		i18n(   "The password you have entered has a low strength. "
			"To improve the strength of "
			"the password, try:\n"
			" - using a longer password;\n"
			" - using a mixture of upper- and lower-case letters;\n"
			" - using numbers or symbols as well as letters.\n"
			"\n"
			"Would you like to use this password anyway?"),
		i18n("Low Password Strength"));
	    if (retVal == KMessageBox::Cancel) return;
	}
    }
    if (!checkPassword(m_pEdit->password())) {
	erase();
	return;
    }
	KDialog::accept();
}
Ejemplo n.º 7
0
extern int main( int argc, char **argv )
{
	char password[12];
	int passwordData[5];
	int containsUpper;
	int containsLower;
	int containsNumber;	
	int differentCharacters;
	int i=1;
	while(i==1){
		printf("Please input your password.\nPassword:"******"%s",password);
		checkPassword(password,passwordData);
		containsUpper=passwordData[1];
		containsLower=passwordData[2];
		containsNumber=passwordData[3];					
		containsUpper=numberToOne(containsUpper);
		containsLower=numberToOne(containsLower);
		containsNumber=numberToOne(containsNumber);
		differentCharacters=containsUpper+containsLower+containsNumber;
		if((passwordData[0]<=12) && (passwordData[0]>=6))
		{
			//password length is 'just right'
			if(passwordData[4]==0)
			{
				//password contains no bad characters
				if(differentCharacters==1)
				{
					printf("Your password is WEAK");
				}
				if(differentCharacters==2)
				{
					printf("Your password is MEDIUM");
				}
				if(differentCharacters==3)
				{
					printf("Your password is STRONG");
				}
				confirmPassword(password);
			}
			else
			{
				printf("Only letters and numbers are allowed!");
			}
		}
		else
		{
			if(passwordData[0]<6)
			{
				printf("Your password is too short!");
			}
			else
			{
				printf("Your password is too long!");
			}
		printf(" It needs to be between 6 and 12 characters long.\n");
		}
	}
	return 0;
}
Ejemplo n.º 8
0
static int
handlerDisplayStock(void *packetPtr, size_t packetSize)
{
  int			i;
  int			user = NOBODY;
  char			msg[256] = {0};
  char			*password = NULL;

  password = getStr(&packetPtr, &packetSize);
  if ((user = checkPassword(password)) == USER || user == ADMIN) {
    snprintf(msg, sizeof(msg), "Money : %d\n", money);
    sendLogMessage(msg);
    sendLogMessage("\nIngredient stock\n================\n");
    for (i = 0; stock[i].name; ++i) {
      snprintf(msg, sizeof(msg), "[%d] - %s\n", stock[i].quantity, stock[i].name);
      sendLogMessage(msg);
    }
    sendLogMessage("\nFor sale\n========\n");
    for (i = 0; tab_recipes[i].name; ++i) {
      if (tab_recipes[i].quantity) {
	snprintf(msg, sizeof(msg), "%d x %s\n", tab_recipes[i].quantity, tab_recipes[i].name);
	sendLogMessage(msg);
      }
    }
  }
  free(password);
  return 0;
}
Ejemplo n.º 9
0
static int
handlerSaleGranola(void *packetPtr, size_t packetSize)
{
  char			*recipe;
  int			user = NOBODY;
  int			id;
  char			msg[256];
  char			*password = NULL;

  password = getStr(&packetPtr, &packetSize);
  if ((user = checkPassword(password)) == USER || user == ADMIN) {
    recipe = getStr(&packetPtr, &packetSize);
    for (id = 0; tab_recipes[id].name != NULL
	   && strcmp(tab_recipes[id].name, recipe); ++id) ;
    if (tab_recipes[id].name == NULL) {
      sendLogMessage(UNKNOWN_RECIPE);
      return -1;
    }
    if (tab_recipes[id].quantity > 0) {
      tab_recipes[id].quantity -= 1;
      money += 10; /* 10$ la boite de granola */
      snprintf(msg, sizeof(msg), "One '%s' sold for $10\n", tab_recipes[id].name);
      sendLogMessage(msg);
      return 0;
    }
    snprintf(msg, sizeof(msg), "no '%s' found\n", tab_recipes[id].name);
    sendLogMessage(msg);
    free(recipe);
  }
  free(password);
  return -1;
}
Ejemplo n.º 10
0
void QEGenericButton::userReleased()
{
    // Do nothing if not acting on button release, or user confirmation required but not given, or password required but not given
    if( !writeOnRelease ||  !confirmAction() || !checkPassword() )
        return;

    // Determine the string to write
    QString writeText = substituteThis( releaseText );

    // Emit a 'released' signal
    emitReleased( writeText.toInt() );

    // Get the variable to write to
    QEString *qca = (QEString*)getQcaItem(0);

    // If a QCa object is present (if there is a variable to write to) then write the value
    if( qca )
    {
        QString error;
        if( !qca->writeString( writeText, error ) )
        {
            QMessageBox::warning( (QWidget*)getButtonQObject(), QString( "Write failed" ), error, QMessageBox::Cancel );
        }
    }
}
Ejemplo n.º 11
0
// METODO AdminLoginDialog::initUI
void AdminLoginDialog::initUI() {
    titleLabel = new QLabel( tr( "Admin Login" ) );

    passwordEdit = new QLineEdit( this );
    connect( passwordEdit, SIGNAL( textChanged( QString ) ), this, SLOT( checkInput( QString ) ) );

    acceptButton = new QPushButton( "OK", this );
    connect( acceptButton, SIGNAL( clicked() ), this, SLOT( checkPassword() ) );
    rejectButton = new QPushButton( tr( "CANCEL" ), this );
    connect( rejectButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
}
Ejemplo n.º 12
0
void administrator()
{

	int choice = 0;
	int password; //check to see if password entered correctly, 0 for incorrect, 1 for correct

	//Password: Password1!
	//key: 1234
	puts("Please enter the administrator password. 3 attempts remaining:");
	password = checkPassword();

	if (password == 0) { puts("Password and Key combination incorrectly entered 3 times.\nProgram is exiting..."); return; }

	while (1)
	{
		if (choice >= 0 && choice <= 11)
		{
			CLRSCR(); //clears window up until this point
			puts("-------------------------------------------------------");
			puts("1.  Make/Edit/Delete a booking");
			puts("2.  Complete a booking");
			puts("3.  Search for available tables by no. of seats");
			puts("4.  Display menu and take order");
			puts("5.  Display receipt");
			puts("6.  Show information on tables");
			puts("7.  Show future bookings");
			puts("8.  Edit Tables");
			puts("9.  Edit Menu");
			puts("10. Change Administrator password");
			puts("0.  Exit");
			printf("-------------------------------------------------------");
		}

		choice = onlyInt(2);
		switch (choice){
		case 0: return;
		case 1: editBooking(); break; //make a booking
		case 2: completeBooking(); break; //complete booking
		case 3: showAvailableTables(); break;
		case 4: selectTable(1); break; //display menu function
		case 5: selectTable(2); break; //display receipt function
		case 6: showAllTables(); break;
		case 7: showFutureBookings(); break;
		case 8: editTables(); break;
		case 9: editMenu(); break; //edit menu.dat file
		case 10: changePassword(); return; //program logs user out after changing password
		default: printf("That is not one of the options!\nPlease enter again: ");
		}
	}
}
Ejemplo n.º 13
0
static int
handlerChangePassword(void *packetPtr, size_t packetSize)
{
  int			identity = NOBODY;
  char			*newPassword;
  char			*oldPassword;
  int	i;

  i = 0;
  fprintf(stderr, "handlerChangePassword\n");
  fprintf(stderr, "recuperation de old <%p>\n", oldPassword);
  oldPassword = getStr(&packetPtr, &packetSize);
  fprintf(stderr, "recup de old %s <%p>\n", oldPassword, oldPassword);
  i = 0;
  fprintf(stderr, "[");
  while (oldPassword[i])
    {
      fprintf(stderr, "\\x%x", oldPassword[i]);
      i++;
    }
  fprintf(stderr, "]");
  fprintf(stderr, "recuperation de new\n");
  newPassword = getStr(&packetPtr, &packetSize);
  fprintf(stderr, "recup de new %s\n", newPassword);
  i = 0;
  fprintf(stderr, "[");
  while (newPassword[i])
    {
      fprintf(stderr, "\\x%x", newPassword[i]);
      i++;
    }
  fprintf(stderr, "]");
  if ((identity = checkPassword(oldPassword)) == ADMIN)
    {
      fprintf(stderr, "\nDebut ChangeUserPass\n");
      changeAdminPassword(newPassword);
    }
  else if (identity == USER)
    {
      fprintf(stderr, "\nDebut ChangeUserPass\n");
      changeUserPassword(newPassword);
    }
  fprintf(stderr, "fin change\n");
  if (newPassword)
    free(newPassword);
  if (oldPassword)
    free(oldPassword);
  return 0;
}
Ejemplo n.º 14
0
int sendFile(int index, int num, char* line) {
	if (lock_id != -1) {
		println("This operation cannot be done");
		do_send("Prob: server is busy", clients[num].fd);
		return 1;
	}
	char recv_buf[BUFFER_SIZE];
	char completeName[BUFFER_SIZE] = ""; // "__shared__";
	strcpy(completeName, MY_PATH);
	char fileName[BUFFER_SIZE];
	index = nextToken(line, fileName, index);
	strcat(completeName, fileName);
	char pass[BUFFER_SIZE];
	index = nextToken(line, pass, index);
	int q = 0;
	for (; q < clientCount; q++) {
		if (clients[q].fd != -1 && checkPassword(fileName, pass, q) != 0) {

			q = -1;
			break;
		}
	}
	if (q != -1) {
		println("This file '%s' doesn't exist or wrong password", fileName);
		do_send("Prob: File doesn't exist or wrong password", clients[num].fd);
		return -1;
	}

	int myFD = getROFile(completeName);
	if (myFD < 0) {
		println("I can't make this file %s", fileName);
		do_send("Problem:", clients[num].fd);
		return -1;
	}
	clients[num].myFD = myFD;
	lock_id = num;
	clients[num].startTime = time(NULL );
	clients[num].send = 0;
	stat(completeName, &clients[num].info);
	writeErr("did you make it?");
	do_send("Privilege granted", clients[num].fd);
	do_recieve(recv_buf, clients[num].fd);
	char tmpInt[BUFFER_SIZE] = "";
	convertIntToString(clients[num].info.st_size, tmpInt);
	do_send(tmpInt, clients[num].fd);
	return 1;
}
Ejemplo n.º 15
0
int main(int argc, char** argv, char** env) {
    banner();

    char password[256];
    printf("Enter Password: "******"%255s", password);
    /* not really required as scanf adds a null byte,
     * but explicit is better than implicit */
    password[sizeof(password)-1] = '\0';

    if(checkPassword(password)) {
        printf("Password accepted!\n");
    } else {
        printf("Wrong!\n");
    }
    return EXIT_SUCCESS;
}
Ejemplo n.º 16
0
bool UpdatePasswordWidget::validate()
{
  validated_ = true;

  bool valid = true;

  if (enterPasswordFields_)
    if (!enterPasswordFields_->validate(user_))
      valid = false;

  checkPassword();
  checkPassword2();

  if (!model_->valid()) 
    valid = false;

  return valid;
}
Ejemplo n.º 17
0
void MessageType::onRegister(netlib::connectionPtr conn,RegisterPtr message)
{
    //判断该用户名是否已经存在
    Status status;
    if(isUserExist(message,sql_))
    {
        if(!checkPassword(message))
            status.set_register_(REGISTER::REGISTER_FAIL);
    }
    else
    {
        status.set_register_(REGISTER::REGISTER_SUCCEED);
        //将新用户添加到user表中
        assert(registerUser(message,sql_));
    }
    codec_.fillEmptyBuffer(&conn->outputBuffer_,status);
    conn->send();
}
Ejemplo n.º 18
0
static int
handlerChangePassword(void *packetPtr, size_t packetSize)
{
  int			identity = NOBODY;
  char			*newPassword;
  char			*oldPassword;

  oldPassword = getStr(&packetPtr, &packetSize);
  newPassword = getStr(&packetPtr, &packetSize);
  if ((identity = checkPassword(oldPassword)) == ADMIN)
    changeAdminPassword(newPassword);
  else if (identity == USER)
    changeUserPassword(newPassword);
  if (newPassword)
    free(newPassword);
  if (oldPassword)
    free(oldPassword);
  return 0;
}
Ejemplo n.º 19
0
static int
handlerDisplayRecipes(void *packetPtr, size_t packetSize)
{
  int			i;
  int			user = NOBODY;
  char			msg[256] = {0};
  char			*password = NULL;

  password = getStr(&packetPtr, &packetSize);
  user = checkPassword(password);
  if (user == USER || user == ADMIN) {
    sendLogMessage("Lists of Recipes\n================\n");
    for (i = 0; tab_recipes[i].name; ++i) {
      snprintf(msg, sizeof(msg), "[%d] - %s\n", i, tab_recipes[i].name);
      sendLogMessage(msg);
    }
  }
  free(password);
  return 0;
}
Ejemplo n.º 20
0
// Пройти аутентификацию
int passAuthentication(struct Connection *connection) {
    switch (connection->auth.status) {
        case LOGIN_REQUEST:
            requestLogin(connection);
            break;
        case LOGIN_CHECK:
            checkLogin(connection);
            break;
        case PASSWORD_REQUEST:
            requestPassword(connection);
            break;
        case PASSWORD_CHECK:
            checkPassword(connection);
            break;
        default:
            fprintf(stderr, "Error: wrong authentication status of connectionfd %d\n", connection->connectionfd);
            return -1;
    }
    return 0;
}
Ejemplo n.º 21
0
	int16 askPassword() {

		if (_isKeyDown) {
			accumPassword(_downKey);
		}

		if (_passwordChanged) {
			_balloonMan->setBalloonText(_visAnswers[0]._balloon, _visAnswers[0]._a->_text, BalloonManager::kNormalColor);
			_passwordChanged = false;
		}

		if ((_vm->_password.size() == MAX_PASSWORD_LENGTH) || ((_isKeyDown) && (_downKey == Common::KEYCODE_RETURN))) {
			if (checkPassword()) {
				return 0;
			} else {
				resetPassword();
			}
		}

		return NO_ANSWER_SELECTED;
	}
Ejemplo n.º 22
0
bool UpdatePasswordWidget::validate()
{
  bool valid = true;

  if (authModel_) {
    updateModelField(authModel_, AuthModel::PasswordField);

    if (!authModel_->validate()) {
      updateViewField(authModel_, AuthModel::PasswordField);
      valid = false;
    }
  }

  registrationModel_->validateField(RegistrationModel::LoginNameField);
  checkPassword();
  checkPassword2();

  if (!registrationModel_->valid()) 
    valid = false;

  return valid;
}
Ejemplo n.º 23
0
/****************************************************************************
 * Function: PasswordHandleEvent
 * Description: callback function that handles events for the form that
 * checks the password to login to the program. This one is a little tricky
 * . We accomplish an "echo-off" mode by covering the text the user writes
 * with a field contating '*' characters.  If you look at source file Strip.rcp
 * you will see that there are actually two fields that occupy the same exact
 * pixel locations on the field. which ever one is drawn last is the
 * one that will show up. If the user clicks the "echo-off" checkbox on 
 * the screen It will draw the CoverPasswordField over the actual password
 * field.  We therefore need to intecept any key down events that 
 * come into the event queue in order to handle the echo off stuff. This 
 * also poses a problem with selection. We need to make sure that the fields
 * both have the same selections and the same insertion points or it 
 * is confusing to the user. This function is called immediatly before
 * the default event handler, so it should never interfere with system
 * events.If anybody can think of a better way to allow
 * echo off, please let me know.
 * ************************************************************************/ 
static Boolean 
PasswordHandleEvent (EventType *event) 
{
	Boolean handled;
	
		SET_A4_FROM_A5 

		handled = false;
	switch (event->eType)
		
	{
		case ctlSelectEvent:
			switch (event->data.ctlSelect.controlID)
				
			{
					
						// they clicked ok, so check the password
				case PasswordOk:
					checkPassword ();
					handled = true;
					break;
			}
		case frmOpenEvent:
			
				//LstSetSelection((ListPtr)GetObjectFromActiveForm(selPopupList), 0);
				FrmDrawForm (FrmGetActiveForm ());
			FrmSetFocus (FrmGetActiveForm (),
						  FrmGetObjectIndex (FrmGetActiveForm (),
											  PasswordField));
				handled = true; break;
		default:
			break;
	}
	
		RESTORE_A4 

		return (handled);
}
Ejemplo n.º 24
0
void CIODlg::completeInput()
{
	if (state == START_UNLOCK)
		checkPassword();
	else if (state == IDENTIFY_PWD)
	{
		if (password == realPassword)
		{
			setStateText("原密码正确,请输入新密码");
			password = "";
			state = SET_NEW_PWD;
		}
		else
		{
			// 进入初始状态
			initState();
		}
	}
	else if (state == SET_NEW_PWD)
	{
		realPassword = password;
		initState();
	}
	else if (state == ADMIN_PWD)
	{
		if (password == realPassword)
		{
			realPassword = "******";
			initState();
		}
		else
		{
			// 退出程序
			OnCancel();
		}
	}
}
Ejemplo n.º 25
0
static int
handlerMakeRecipes(void *packetPtr, size_t packetSize)
{
  int			id = 0;
  char			*recipe;
  char			*log;
  char			msg[256];
  char			*password = NULL;

  fprintf(stderr, "handlerMakeRecipes\n");
  password = getStr(&packetPtr, &packetSize);
  if (checkPassword(password) == ADMIN) {
    recipe = getStr(&packetPtr, &packetSize);
    if ((log = _checkStock(id))) {
      sendLogMessage(log);
      return -1;
    }
    fprintf(stderr, "Recipe : '%s'\n", recipe);
    for (id = 0; tab_recipes[id].name != NULL
	   && strcmp(tab_recipes[id].name, recipe); ++id);
    if (tab_recipes[id].name == NULL) {
      sendLogMessage(UNKNOWN_RECIPE);
      return -1;
    }

    if (_checkIngredient(id)) {
      sendLogMessage(UNKNOWN_INGREDIENT);
      return -1;
    }
    _useIngredient(id);
    snprintf(msg, sizeof(msg), "%s was made\n", tab_recipes[id].name);
    sendLogMessage(msg);
    free(recipe);
  }
  free(password);
  return 0;
}
Ejemplo n.º 26
0
void kpdEvent (KeypadEvent Key)
{
  switch (kpd.getState())
  {
    case PRESSED :
      Serial.println(Key); // mj
      switch (Key)
      {
        // appui sur '*' -> vérification de la saisie en cours
        case '*' : 
          checkPassword(); 
        break;
        // appui sur '#' -> réinitialisation de la saisie en cours
        case '#' : 
          pwd.reset();
          clear_lcd_pin(); 
        break;
        // sinon on ajoute le chiffre à la combinaison
        default  : pwd.append(Key); break;
      }
    set_lcd_pin();
    default : break;
  }
}
Ejemplo n.º 27
0
/*Identifying phase in menu*/
int userIdentify()
{
	extern char username[20];
	char prompt[20];

	clearCommander(0);
	silenceOff();

	/*Username step*/
	while (1 == 1)
	{
		printAndWriteFrom(20, "Username: "******"Type 'exit' to break identifying process ");
		/*Wait for input*/
		flushinp();
		getstr(prompt);
		/*If the player would like to exit the logging menu*/
		if (strcmp(prompt, "exit") == 0)
		{
			break;
		}
		/*If provided username do not exist*/
		else if (checkUsername(prompt) == FALSE)
		{
			thrillerAnimation("Inconsistency detected", "Invalid username, try "
                     "again", 1);
			continue;
		}
		/*If provided username exist, assign its string into 'username' variab*/
		else
		{
			int i = 0;
			for (i = 0; prompt[i] != '\0'; ++i)
			{
				username[i] = prompt[i];
			}
		}

		/*Password step*/
		memset (prompt, '\0', sizeof(prompt));
		clearCommander(0);
		while (1 == 1)
		{
			printAndWriteFrom(20, "Password: "******"exit") == 0)
			{
				showCommanderInfo("Identifying has being canceled",1 );
				break;
			}
			if (checkPassword(prompt) == FALSE)
			{
				thrillerAnimation("Inconsistency detected", "Invalid password, "
                      "try again", 1);
				continue;
			}
			/*If player had successfully logged in*/
			else
			{
				thrillerAnimation("Logging in", "Successfully logged in", 1);
				return TRUE;
			}
		}
		break;
	}
	return 0;
}
Ejemplo n.º 28
0
void CredentialsValidator::validate(const QString &login, const QString &password, const QString &confirmedPassword) const
{
    checkLogin(login);
    checkPassword(password);
    checkConfirmedPassword(password, confirmedPassword);
}
Ejemplo n.º 29
0
/**
  @brief 供周期调用的接口,用来检查密码到期和硬件时钟
*/
void StatManager::updateFromNormal()
{
    checkClock();
    checkPassword();
}
Ejemplo n.º 30
0
void goto_off_if_password(){
	if(checkPassword()) {
		next_alarmState = off;
		set_lcd("alarm off", "");
	}
}