Skip to content

USER UPDATE PASSWORD

ElbyFross edited this page Jan 20, 2020 · 3 revisions

Remarks

An IQueryHandler that updates a password fo a certain user.

  • Located at the AuthorityController.Queries namespace into the USER_UPDATE_PASSWORD class.
  • In case if a requester is not the same user then the rank must be higher than the rank of user that will updated.

By default requires following rights from a requester:

  • passwordManaging

Demanded rights could be modified via the Config by change the QUERY_UserNewPassword_RIGHTSfield's value.

Query's parts

The query must contains all the listed parameters.

Keyword Description
user id or login of the user that will be updated.
update NULL
password A new password in an open format.
oldPassword An old password of the user. Using for confirmation. Demands only in case of self update.
token A guest token provided to a client app.
guid An unique GUID of the query.

Query results

In case if banned success the returns success message using the UniformServer.BaseServer.SendAnswerViaPP.

Error Message
User not found "ERROR 404: User not found"
Invalid SQL query "ERROR SQL SERVER: DATAILS", where DATAILS is an asnwer of the SQL server.
Target user has undefined rank "ERROR 401: User rank not defined"
Not enough rights "ERROR 401: Unauthorized"
Incorrect old password. (Only for self update) "ERROR 412: Incorrect password"
Old password not found in the query "ERROR 412: Confirm old password"

Example

The following example demostrates executing of the USER UPDATE PASSWORD query. In that example the user change the password to themself.

C#

// Creating an update query.
Query query = new Query(
    new QueryPart("token", USER_TOKEN),
    new QueryPart("guid", Guid.NewGuid().ToString()),

    new QueryPart("user", USER_ID),
    new QueryPart("update"),

    new QueryPart("password", NEW_PASSWORD),
    new QueryPart("oldpassword", OLD_PASSWORD),
    new QueryPart("os", Environment.OSVersion.VersionString),
    new QueryPart("mac", PipesProvider.Networking.Info.MacAdsress),
    new QueryPart("stamp", DateTime.Now.ToBinary().ToString())
);

// Starting a client line.
UniformClient.BaseClient.EnqueueDuplexQueryViaPP(
    SERVER_IP, PIPE_NAME,

    query,

    // A handler that will recive an answer from the server.
    (PipesProvider.Client.TransmissionLine line, Query answer) =>
    {
        string first = answer.First.PropertyValueString;

        if (first.StartsWith("error", StringComparison.OrdinalIgnoreCase))
        {
           // Handle error here.
        }
    });
  • Where TOKEN is an unique session token provided to an app\user by the SessionProvider server or by some custom equivalent.
  • Where the SERVER_IP is an ip adress or the name of the computer into a local network.
  • Where the PIPE_NAME is a name of the named pipe started on the server.

Related links

Projects

  • UDO Tests from the ACTests. Look at the UserSetPassword method.
  • Queries Tests from the ACTests. Look at the NewPassword_Self, NewPassword_ModeratorToAdmin, NewPassword_AdminToUser methods.

Related pages