github.com/decred/politeia@v1.4.0/politeiawww/plugin/v1/usermanager.go (about)

     1  // Copyright (c) 2022 The Decred developers
     2  // Use of this source code is governed by an ISC
     3  // license that can be found in the LICENSE file.
     4  
     5  package v1
     6  
     7  import "database/sql"
     8  
     9  // UserManager provides methods that result in state changes to the user
    10  // database that cannot be done inside of plugins.
    11  //
    12  // For example, plugins do not have access to the user database methods that
    13  // insert users into the database. These actions must be done by the backend.
    14  // The UserManager interface allows plugins to add plugin specific behavior
    15  // onto these actions.
    16  //
    17  // Any changes made to the User during method execution will be persisted by
    18  // the caller.
    19  type UserManager interface {
    20  	// ID returns the plugin ID.
    21  	ID() string
    22  
    23  	// Version returns the lowest supported plugin API version.
    24  	Version() uint32
    25  
    26  	// NewUserCmd executes a command that results in a new user being added to
    27  	// the database. The user provided to this method is a newly created user
    28  	// that has not been inserted into the user database yet, but will be
    29  	// inserted if this command executes successfully without any user errors
    30  	// or unexpected errors.
    31  	NewUser(*sql.Tx, WriteArgs) (*Reply, error)
    32  }