Esempio n. 1
0
/**
 * when the create account button is clicked
 * @brief CreateAccount::on_createButton_clicked
 */
void CreateAccount::on_createButton_clicked(){
    QString email = ui->email->text();
    QString pass = ui->password->text();
    QString confPass = ui->confirmPassword->text();
    bool canProceed = true;

    if( !email.contains( QRegExp( "[\\w|.|-]*@\\w*\\.[\\w|.]*" ) ) ){
        alert( "Invalid Email", "Enter a valid email" );
        canProceed = false;
        return;
    }

    if( pass != confPass ){
        alert( "Mismatching Password", "Passwords do not match" );
        canProceed = false;
        return;
    }

    if( canProceed ){
        IO io;
        QByteArray passHash = QCryptographicHash::hash( pass.toUtf8(), QCryptographicHash::Sha1 );
        QString passSha = passHash.toHex();
        io.saveUser( email, passSha );
        this->close();
    }
}