<commit_before>package models

import (
	"crypto/rsa"
	"fmt"
	"time"

	"github.com/dgrijalva/jwt-go"
	"gopkg.in/mgo.v2/bson"
)

// User model.
type User struct {
	Id       bson.ObjectId `json:"_id,omitempty" bson:"_id,omitempty"`
	Login    string        `json:"login" bson:"login,omitempty"`
	Password string        `json:"password" bson:"password,omitempty"`
	Email    string        `json:"email" bson:"email,omitempty"`
}

// Implement stringer
func (u User) String() string {
	return fmt.Sprintf("Id: %v\tLogin: %v\tPassword: %v\tEmail: %v\n", u.Id, u.Login, u.Password, u.Email)
}

// NewToken creates a new token using private key.
// pk - the private key.
func (u User) NewToken(pk *rsa.PrivateKey) (string, error) {
	token := jwt.New(jwt.SigningMethodRS256)
	token.Claims["email"] = u.Email
	token.Claims["login"] = u.Login
	token.Claims["iat"] = time.Now().Unix()<commit_msg>Add payload for user model.<commit_after>package models

import (
	"crypto/rsa"
	"fmt"
	"time"

	"github.com/dgrijalva/jwt-go"
	"gopkg.in/mgo.v2/bson"
)

// User model.
type User struct {
	Id       bson.ObjectId `json:"_id,omitempty" bson:"_id,omitempty"`
	Login    string        `json:"login" bson:"login,omitempty"`
	Password string        `json:"password" bson:"password,omitempty"`
	Email    string        `json:"email" bson:"email,omitempty"`
	Payload  string        `json:"payload,omitempty" bson:"payload,omitempty"`
}

// Implement stringer
func (u User) String() string {
	return fmt.Sprintf("Id: %v\tLogin: %v\tPassword: %v\tEmail: %v\nPayload: %v", u.Id, u.Login, u.Password, u.Email, u.Payload)
}

// NewToken creates a new token using private key.
// pk - the private key.
func (u User) NewToken(pk *rsa.PrivateKey) (string, error) {
	token := jwt.New(jwt.SigningMethodRS256)
	token.Claims["email"] = u.Email
	token.Claims["login"] = u.Login
	token.Claims["iat"] = time.Now().Unix()
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.004259850905218318, 'mean_word_length': 3.8932291666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2431424', 'n_tokens_mistral': 705, 'n_tokens_neox': 698, 'n_words': 155}