src/AdminStore.php
public function adm_self_add_user_passwordless($args) {
		if ($this->store_is_logged_in())
			return [AdminStoreError::USER_ALREADY_LOGGED_IN];

		# check vars
		if (!isset($args['service']))
			return [AdminStoreError::DATA_INCOMPLETE];
		$uname = $uservice = null;
		$service = Common::check_idict($args['service'],
			['uname', 'uservice']);
		if (!$service)
			return [AdminStoreError::DATA_INCOMPLETE];
		extract($service);

		$dbuname = '+' . $uname . ':' . $uservice;
		$check = $this->store->query(
			"SELECT uid FROM udata WHERE uname=? LIMIT 1",
			[$dbuname]);
		$uid = $check
			? $check['uid']
			: $this->store->insert("udata", [
					'uname' => $dbuname,
				], 'uid');

		# token generation is a little different
		$token = $this->generate_secret(
			$dbuname . uniqid(), $uname);

		# explicitly use byway expiration, default column value
		# is strictly for standard expiration
		$date_expire = $this->store->query(
			sprintf(
				"SELECT %s AS date_expire",
				$this->store->stmt_fragment(
					'datetime',
					['delta' => $this->byway_expiration])
				)
			)['date_expire'];

		# insert
		$sid = $this->store->insert('usess', [
			'uid' => $uid,
			'token' => $token,
			'expire' => $date_expire,
		], 'sid');

		# use token for next request
		$this->logger->info("Zapmin: usradd: OK: $uid:'$dbuname'.");
		return [0, [
			'uid' => $uid,
			'uname' => $dbuname,
			'token' => $token,
			'sid' => $sid,
		]];
	}
public function adm_self_add_user_passwordless($args) {
		if ($this->store_is_logged_in())
			return [AdminStoreError::USER_ALREADY_LOGGED_IN];

		# check vars
		if (!isset($args['service']))
			return [AdminStoreError::DATA_INCOMPLETE];
		$uname = $uservice = null;
		$service = Common::check_idict($args['service'],
			['uname', 'uservice']);
		if (!$service)
			return [AdminStoreError::DATA_INCOMPLETE];
		extract($service);

		$dbuname = '+' . $uname . ':' . $uservice;
		$check = $this->store->query(
			"SELECT uid FROM udata WHERE uname=? LIMIT 1",
			[$dbuname]);
		$uid = $check
			? $check['uid']
			: $this->store->insert("udata", [
					'uname' => $dbuname,
				], 'uid');

		# token generation is a little different
		$token = $this->generate_secret(
			$dbuname . uniqid(), $uname);

		# explicitly use byway expiration, default column value
		# is strictly for standard expiration
		$date_expire = $this->store->query(
			sprintf(
				"SELECT %s AS date_expire",
				$this->store->stmt_fragment(
					'datetime',
					['delta' => $this->byway_expiration])
				)
			)['date_expire'];

		# insert
		$sid = $this->store->insert('usess', [
			'uid' => $uid,
			'token' => $token,
			'expire' => $date_expire,
		], 'sid');

		# use token for next request
		$this->logger->info("Zapmin: usradd: OK: $uid:'$dbuname'.");
		return [0, [
			'uid' => $uid,
			'uname' => $dbuname,
			'token' => $token,
			'sid' => $sid,
		]];
	}
public function adm_self_add_user_passwordless ( $ args ) { if ( $ this -> store_is_logged_in ( ) ) return [ AdminStoreError :: USER_ALREADY_LOGGED_IN ] ; # check vars if ( ! isset ( $ args [ 'service' ] ) ) return [ AdminStoreError :: DATA_INCOMPLETE ] ; $ uname = $ uservice = null ; $ service = Common :: check_idict ( $ args [ 'service' ] , [ 'uname' , 'uservice' ] ) ; if ( ! $ service ) return [ AdminStoreError :: DATA_INCOMPLETE ] ; extract ( $ service ) ; $ dbuname = '+' . $ uname . ':' . $ uservice ; $ check = $ this -> store -> query ( "SELECT uid FROM udata WHERE uname=? LIMIT 1" , [ $ dbuname ] ) ; $ uid = $ check ? $ check [ 'uid' ] : $ this -> store -> insert ( "udata" , [ 'uname' => $ dbuname , ] , 'uid' ) ; # token generation is a little different $ token = $ this -> generate_secret ( $ dbuname . uniqid ( ) , $ uname ) ; # explicitly use byway expiration, default column value # is strictly for standard expiration $ date_expire = $ this -> store -> query ( sprintf ( "SELECT %s AS date_expire" , $ this -> store -> stmt_fragment ( 'datetime' , [ 'delta' => $ this -> byway_expiration ] ) ) ) [ 'date_expire' ] ; # insert $ sid = $ this -> store -> insert ( 'usess' , [ 'uid' => $ uid , 'token' => $ token , 'expire' => $ date_expire , ] , 'sid' ) ; # use token for next request $ this -> logger -> info ( "Zapmin: usradd: OK: $uid:'$dbuname'." ) ; return [ 0 , [ 'uid' => $ uid , 'uname' => $ dbuname , 'token' => $ token , 'sid' => $ sid , ] ] ; }
Passwordless self-registration.

This byway registration doesn't differ sign in and sign up.
Use this with caution, e.g. with proper authentication via
OAuth*, SMTP or the like. Unlike add user with password, this
also returns `sid` to associate `session.sid` with a column
on different table.

@param array $args Dict of the form:
@code
(dict){
'service': (dict){
'uname': (string uname),
'uservice': (string uservice)
}
}
@endcode

@return array An array of the form:
@code
(array)[
(int errno),
(dict){
'uid': (int uid),
'uname': (string uname),
'token': (string token)
'sid': (int sid),
}
]
@endcode
Passwordless self - registration .