Skip to content

username issues #2

@AusiMods

Description

@AusiMods

with a clean install from current files and using the offered sql.

its apparent that the user name requires more validation than "string" since the default account "Dignity Dev @Africa/Lagos"
is unworkable due to the slash. Not hard to duplicate just try visiting that account from pretty much any link

this can easily be sorted by removing the username in the sql however to make a fix could be done by adding an alpha validation

<?php

	namespace validation;
	require_once 'ValidInterface.php';


	class Alpha implements ValidInterface
	{

		private $name;
		private $value;

		public function __construct($name, $value)
		{
			$this->name = $name;
			$this->value = $value;

		}

		public function validate()
		{
			if (!ctype_alpha($this->value)) {
				return "$this->name must be alphabetic characters";
			}

			return '';
		}
	}

or an alphanumeric

<?php
namespace validation;
require_once 'ValidInterface.php';


class Alphanum implements ValidInterface {

    private $name;
    private $value;

    public function __construct($name , $value) {
         $this->name = $name;
         $this->value = $value;

    }
    public function validate() {
    	// AlphaNumeric + underscore
		if (!preg_match('/[^a-z_\0-9]/i', $this->value)) {
            return "$this->name must be alpha numeric characters";
        }

        return '';
    }
}

add to validator.php

else if ($rule == 'alpha') {
				$error =  $this->makeValidation(new Alpha($name , $value));
			} else if ($rule == 'alphanum') {
				$error =  $this->makeValidation(new Alphanum($name , $value));
            }

alter the handlesignup.php, handleUpdateData.php and handleAccountSetting to use one of the new entries instead of string
there may be other places these were just some obvious ones :)

The above fix would once added ensure complient "names" and "usernames"

Thanks again for the script :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions