Skip to content
Maximvdw edited this page Nov 5, 2014 · 3 revisions

User Manager

Introduction

User authentication has various advantages. It allows getting more data from the Spigot site since users have more rights then guests and it also allows getting personal information that not everyone can see.

But perhaps the biggest reason to authenticate a use could be to edit specific things on the Spigot site or add posts, messages ,...

The user manager also provides the gathering of other users and interact with them.

Usage

All actions involving spigot users require the User manager.

UserManager userManager = SpigotSite.getAPI().getUserManager();

Authentication

To authenticate a user you will need his username and password. Spigot does not support sending hashed passwords so you will need the users plain password.

User user = userManager.authenticate("md_5","I<3Spigot");

The user manager will return the user on a successful authentication. Since this authentication is done live you should always use this on a separated thread or task.

A user only needs to be authenticated once during the existence of that user instance. You can dig deeper into the SpigotSite plugin to store the cookies.

Logging off

Logging off is crucial if you want to dispose of the current session and change the online status on the site.The user will remain online on the Spigot site for as long as the spigot API is using the user instance.

Getting a user

There will be situations you have to get a user by its identifier. To make the API as fast as possible won't automatically get all user data when the user is referred on another page.

For example if you get a user from a resource it will only contain his username and userid.

User user = userManager.getUserById(1);

The code above will give you the user with user id 1 (md_5)

Clone this wiki locally