CreateNewSession(response http.ResponseWriter, userID string, payload ...map[string]interface{}) (Session, error)
Parameters
response
- description: Response writer object from your API handler
userId
- description: Should be used to ID a user in your system.
payload
- description: There are two types of payloads:
- JWT Payloads: This must be at index 0 of the
payload
param. This information is stored in the JWT sent to the frontend, so it should not contain any sensitive information. Theinterface{}
in the map can be any of the primitive types, an[]interface{}
or anothermap[string]interface{}
. - Session Data: This must be at index 1 of the
payload
param. This information is stored only in your database, so it can contain sensitive information. Theinterface{}
in the map can be any of the primitive types, an[]interface{}
or anothermap[string]interface{}
.
- JWT Payloads: This must be at index 0 of the
- description: There are two types of payloads:
CreateNewSession(c *gin.Context, userID string, payload ...map[string]interface{}) (Session, error)
Parameters
c
- description: Context object from your API handler
userId
- description: Should be used to ID a user in your system.
payload
- description: There are two types of payloads:
- JWT Payloads: This must be at index 0 of the
payload
param. This information is stored in the JWT sent to the frontend, so it should not contain any sensitive information. Theinterface{}
in the map can be any of the primitive types, an[]interface{}
or anothermap[string]interface{}
. - Session Data: This must be at index 1 of the
payload
param. This information is stored only in your database, so it can contain sensitive information. Theinterface{}
in the map can be any of the primitive types, an[]interface{}
or anothermap[string]interface{}
.
- JWT Payloads: This must be at index 0 of the
- description: There are two types of payloads:
Returns
Session
on successful creation of a session. To know more about theSession
object, click here- GeneralError if something goes wrong
Additional information
- Creates a new access, a new refresh and a new idRefresh token for this session. These are set in the cookies and header of the
ctx
object.