Example #1
0
void Tracker::CreateAndStoreAccountHandleReply() {
  QNetworkReply *reply = static_cast< QNetworkReply* >( sender() );
  if( reply->error() == QNetworkReply::NoError ) {
    LOG( "Account creation was successful!" );

    QByteArray jsonData = reply->readAll();

    bool ok;
    QtJson::JsonObject user = QtJson::parse( jsonData, ok ).toMap();

    if( !ok ) {
      LOG( "Couldn't parse response" );
    } else {
      LOG( "Welcome %s", user[ "username" ].toString().toStdString().c_str() );

      SetUsername( user["username"].toString() );
      SetPassword( user["password"].toString() );

      emit AccountCreated();
    }
  } else {
    int statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
    LOG( "There was a problem creating an account. Error: %i HTTP Status Code: %i", reply->error(), statusCode );
  }
}
Example #2
0
File: q.cpp Project: ZachBeta/znc
	virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
		if (!sArgs.empty()) {
			SetUsername(sArgs.Token(0));
			SetPassword(sArgs.Token(1));
		} else {
			m_sUsername = GetNV("Username");
			m_sPassword = GetNV("Password");
		}

		CString sTmp;
		m_bUseCloakedHost = (sTmp = GetNV("UseCloakedHost")).empty() ? true : sTmp.ToBool();
		m_bUseChallenge   = (sTmp = GetNV("UseChallenge")).empty()  ? true : sTmp.ToBool();
		m_bRequestPerms   = GetNV("RequestPerms").ToBool();

		OnIRCDisconnected(); // reset module's state

		if (IsIRCConnected()) {
			// check for usermode +x if we are already connected
			set<unsigned char> scUserModes = GetUser()->GetIRCSock()->GetUserModes();
			if (scUserModes.find('x') != scUserModes.end())
				m_bCloaked = true;

			OnIRCConnected();
		}

		return true;
	}
NS_IMETHODIMP
nsSmtpServer::GetUsernamePasswordWithUI(const PRUnichar * aPromptMessage, const
                                PRUnichar *aPromptTitle,
                                nsIAuthPrompt* aDialog,
                                nsACString &aUsername,
                                nsACString &aPassword)
{
  nsresult rv;
  if (!m_password.IsEmpty())
  {
    rv = GetUsername(aUsername);
    NS_ENSURE_SUCCESS(rv, rv);

    return GetPassword(aPassword);
  }

  NS_ENSURE_ARG_POINTER(aDialog);

  nsCString serverUri;
  rv = GetServerURI(serverUri);
  NS_ENSURE_SUCCESS(rv, rv);

  nsString uniUsername;
  nsString uniPassword;
  bool okayValue = true;

  rv = aDialog->PromptUsernameAndPassword(aPromptTitle, aPromptMessage,
                                          NS_ConvertASCIItoUTF16(serverUri).get(),
                                          nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
                                          getter_Copies(uniUsername),
                                          getter_Copies(uniPassword),
                                          &okayValue);
  NS_ENSURE_SUCCESS(rv, rv);

  // If the user pressed cancel, just return emtpy strings.
  if (!okayValue)
  {
    aUsername.Truncate();
    aPassword.Truncate();
    return rv;
  }

  // We got a username and password back...so remember them.
  NS_LossyConvertUTF16toASCII username(uniUsername);

  rv = SetUsername(username);
  NS_ENSURE_SUCCESS(rv, rv);

  NS_LossyConvertUTF16toASCII password(uniPassword);

  rv = SetPassword(password);
  NS_ENSURE_SUCCESS(rv, rv);

  aUsername = username;
  aPassword = password;
  return NS_OK;
}
  void OrthancPeerParameters::FromJson(const Json::Value& peer)
  {
    if (!peer.isArray() ||
        (peer.size() != 1 && peer.size() != 3))
    {
      throw OrthancException(ErrorCode_BadFileFormat);
    }

    std::string url;

    try
    {
      url = peer.get(0u, "").asString();

      if (peer.size() == 1)
      {
        SetUsername("");
        SetPassword("");
      }
      else if (peer.size() == 3)
      {
        SetUsername(peer.get(1u, "").asString());
        SetPassword(peer.get(2u, "").asString());
      }
      else
      {
        throw OrthancException(ErrorCode_BadFileFormat);
      }
    }
    catch (...)
    {
      throw OrthancException(ErrorCode_BadFileFormat);
    }

    if (url.size() != 0 && url[url.size() - 1] != '/')
    {
      url += '/';
    }

    SetUrl(url);
  }
Example #5
0
status_t
GoogleTalk::UpdateSettings( BMessage & msg )
{
	const char *username = NULL;
	const char *password = NULL;
	const char *res = NULL;
	
	msg.FindString("username", &username);
	msg.FindString("password", &password);
	msg.FindString("resource", &res);
	
	if ( (username == NULL) || (password == NULL) ){ 
		LOG( kProtocolName, liHigh, "Invalid settings!");
		return B_ERROR;
	};
	
	fUsername = username;
	int32 atpos=fUsername.FindLast("@");
	if(	 atpos> 0 ) {
		BString server;
		fUsername.CopyInto(server,atpos + 1,fUsername.Length()-atpos);
		fUsername.Remove(atpos,fUsername.Length()-atpos);
		LOG( kProtocolName, liHigh, "Server %s\n",server.String());
		fServer = server;		
	}
	else
		fServer.SetTo("gmail.com");
		
	
	fPassword = password;
	
	SetUsername(fUsername);
	SetHost(fServer);
	SetPassword(fPassword);
	
	if(strlen(res)==0)
		SetResource("IMKit GoogleTalk AddOn");
	else
		SetResource(res);
	
	SetPriority(5);
	SetPort(5222);
	
	return B_OK;
}
Example #6
0
File: q.cpp Project: ZachBeta/znc
	void Auth(const CString& sUsername = "", const CString& sPassword = "") {
		if (m_bAuthed)
			return;

		if (!sUsername.empty())
			SetUsername(sUsername);
		if (!sPassword.empty())
			SetPassword(sPassword);

		if (m_sUsername.empty() || m_sPassword.empty()) {
			PutModule("You have to set a username and password to use this module! See 'help' for details.");
			return;
		}

		if (m_bUseChallenge) {
			PutModule("Auth: Requesting CHALLENGE...");
			m_bRequestedChallenge = true;
			PutQ("CHALLENGE");
		} else {
			PutModule("Auth: Sending AUTH request...");
			PutQ("AUTH " + m_sUsername + " " + m_sPassword);
		}
	}
Example #7
0
status_t
Jabber::UpdateSettings( BMessage & msg )
{
	const char *username = NULL;
	const char *server=NULL;
	const char *password = NULL;
	const char *res = NULL;
	
	msg.FindString("username", &username);
	msg.FindString("server",&server);
	msg.FindString("password", &password);
	msg.FindString("resource", &res);
	
	if ( (username == NULL) || (password == NULL) || (server == NULL)) {
//		invalid settings, fail
		LOG( kProtocolName, liHigh, "Invalid settings!");
		return B_ERROR;
	};
	
	fUsername = username;
	fServer = server;
	fPassword = password;
	
	SetUsername(fUsername);
	SetHost(fServer);
	SetPassword(fPassword);
	
	if(strlen(res)==0)
		SetResource("IMKit Jabber AddOn");
	else
		SetResource(res);
	
	SetPriority(5);
	SetPort(5222);
	
	return B_OK;
}
Example #8
0
void CScrobbler::LoadCredentials()
{
    SetUsername("");
    SetPassword("");
}
void CLibrefmScrobbler::LoadCredentials()
{
  SetUsername(g_guiSettings.GetString("scrobbler.librefmusername"));
  SetPassword(g_guiSettings.GetString("scrobbler.librefmpass"));
}
void MainProgramWindow::on_pushButton_Login_clicked()
{
	Admin	Administrator("admin","*****@*****.**", 1234, "password");
	int		customerLocation;
	bool	validInput = false;
	QString tempName;
	QString tempPassword;
	Login   loginWindow;
	ErrorLogin errorWindow;
	Customer tempCustomer;


	customerLocation = 0;
	loginWindow.setModal(true);
    int success = loginWindow.exec();
	loginWindow.on_buttonBox_loginPress_accepted(tempName, tempPassword);

	// Stores the tempname and password
	SetUsername(tempName);
	SetPassword(tempPassword);

	if(Administrator.checkAdmin(tempName, tempPassword ))
	{
		validInput = true;
		SetAdminLogin(true);
	}
	else
	{	// Compare user input to database

        try
        {
            tempCustomer = customerList.FindCustomer(tempName);

            if (tempCustomer.getAccess() && tempCustomer.getPassword() == tempPassword)
            {
                validInput = true;
                SetCustomerLogin(true);
            }
            else if (tempCustomer.getPassword() != tempPassword)
            {
                QMessageBox::information(this,"Error", "Wrong Credentials, sorry.");
            }
            else
            {
                QMessageBox::information(this,"Message", "Your account has not been activated yet. An administrator needs to activate your account, thank you for your patience!");

            }

        }
        catch (NotFound)
        {
            if (success)
            {
                QMessageBox::information(this,"Error", "Account not found, sorry.");
            }
        }
        catch(...)
        {

        }


	}

	if(validInput)
	{
		if(adminLogin)
		{
			aWindow->show();	// ADMIN
		}
		else if(customerLogin)
		{
			if(tempCustomer.getAccess())
			{

				bWindow->show();    // BROCHURE
            }
		}


	}

    //restore defaults
    SetAdminLogin(false);
    SetCustomerLogin(false);

}
Example #11
0
File: q.cpp Project: ZachBeta/znc
	virtual void OnModCommand(const CString& sLine) {
		CString sCommand = sLine.Token(0).AsLower();

		if (sCommand == "help") {
			PutModule("The following commands are available:");
			CTable Table;
			Table.AddColumn("Command");
			Table.AddColumn("Description");
			Table.AddRow();
			Table.SetCell("Command", "Auth [<username> <password>]");
			Table.SetCell("Description", "Tries to authenticate you with Q. Both parameters are optional.");
			Table.AddRow();
			Table.SetCell("Command", "Cloak");
			Table.SetCell("Description", "Tries to set usermode +x to hide your real hostname.");
			Table.AddRow();
			Table.SetCell("Command", "Status");
			Table.SetCell("Description", "Prints the current status of the module.");
			Table.AddRow();
			Table.SetCell("Command", "Update");
			Table.SetCell("Description", "Re-requests the current user information from Q.");
			Table.AddRow();
			Table.SetCell("Command", "Set <setting> <value>");
			Table.SetCell("Description", "Changes the value of the given setting. See the list of settings below.");
			Table.AddRow();
			Table.SetCell("Command", "Get");
			Table.SetCell("Description", "Prints out the current configuration. See the list of settings below.");
			PutModule(Table);

			PutModule("The following settings are available:");
			CTable Table2;
			Table2.AddColumn("Setting");
			Table2.AddColumn("Type");
			Table2.AddColumn("Description");
			Table2.AddRow();
			Table2.SetCell("Setting", "Username");
			Table2.SetCell("Type", "String");
			Table2.SetCell("Description", "Your Q username.");
			Table2.AddRow();
			Table2.SetCell("Setting", "Password");
			Table2.SetCell("Type", "String");
			Table2.SetCell("Description", "Your Q password.");
			Table2.AddRow();
			Table2.SetCell("Setting", "UseCloakedHost");
			Table2.SetCell("Type", "Boolean");
			Table2.SetCell("Description", "Whether to cloak your hostname (+x) automatically on connect.");
			Table2.AddRow();
			Table2.SetCell("Setting", "UseChallenge");
			Table2.SetCell("Type", "Boolean");
			Table2.SetCell("Description", "Whether to use the CHALLENGEAUTH mechanism to avoid sending passwords in cleartext.");
			Table2.AddRow();
			Table2.SetCell("Setting", "RequestPerms");
			Table2.SetCell("Type", "Boolean");
			Table2.SetCell("Description", "Whether to request voice/op from Q on join/devoice/deop.");
			PutModule(Table2);

			PutModule("This module takes 2 optional parameters: <username> <password>");
			PutModule("Module settings are stored between restarts.");

		} else if (sCommand == "set") {
			CString sSetting = sLine.Token(1).AsLower();
			CString sValue   = sLine.Token(2);
			if (sSetting.empty() || sValue.empty()) {
				PutModule("Syntax: Set <setting> <value>");
			} else if (sSetting == "username") {
				SetUsername(sValue);
				PutModule("Username set");
			} else if (sSetting == "password") {
				SetPassword(sValue);
				PutModule("Password set");
			} else if (sSetting == "usecloakedhost") {
				SetUseCloakedHost(sValue.ToBool());
				PutModule("UseCloakedHost set");
				if (m_bUseCloakedHost && IsIRCConnected())
					Cloak();
			} else if (sSetting == "usechallenge") {
				SetUseChallenge(sValue.ToBool());
				PutModule("UseChallenge set");
			} else if (sSetting == "requestperms") {
				SetRequestPerms(sValue.ToBool());
				PutModule("RequestPerms set");
			} else
				PutModule("Unknown setting: " + sSetting);

		} else if (sCommand == "get" || sCommand == "list") {
			CTable Table;
			Table.AddColumn("Setting");
			Table.AddColumn("Value");
			Table.AddRow();
			Table.SetCell("Setting", "Username");
			Table.SetCell("Value", m_sUsername);
			Table.AddRow();
			Table.SetCell("Setting", "Password");
			Table.SetCell("Value", "*****"); // m_sPassword
			Table.AddRow();
			Table.SetCell("Setting", "UseCloakedHost");
			Table.SetCell("Value", CString(m_bUseCloakedHost));
			Table.AddRow();
			Table.SetCell("Setting", "UseChallenge");
			Table.SetCell("Value", CString(m_bUseChallenge));
			Table.AddRow();
			Table.SetCell("Setting", "RequestPerms");
			Table.SetCell("Value", CString(m_bRequestPerms));
			PutModule(Table);

		} else if (sCommand == "status") {
			PutModule("Connected: " + CString(IsIRCConnected() ? "yes" : "no"));
			PutModule("Cloaked: "   + CString(m_bCloaked       ? "yes" : "no"));
			PutModule("Authed: "    + CString(m_bAuthed        ? "yes" : "no"));

		} else {
			// The following commands require an IRC connection.
			if (!IsIRCConnected()) {
				PutModule("Error: You are not connected to IRC.");
				return;
			}

			if (sCommand == "cloak") {
				if (!m_bCloaked)
					Cloak();
				else
					PutModule("Error: You are already cloaked!");

			} else if (sCommand == "auth") {
				if (!m_bAuthed)
					Auth(sLine.Token(1), sLine.Token(2));
				else
					PutModule("Error: You are already authed!");

			} else if (sCommand == "update") {
				WhoAmI();
				PutModule("Update requested.");

			} else {
				PutModule("Unknown command. Try 'help'.");
			}
		}
	}
Example #12
0
LoginResultRequest::LoginResultRequest(const std::string& username, LoginResultRequest::Result result, const std::string& message) {
    SetUsername(username);
    SetResult(result);
    SetMessage(message);
}