<commit_before>import Authentication
import FluentProvider
import JWT
import JWTProvider
import SMTP

/// Defines basic user that can be authorized.
public final class User: Model, Timestampable, SoftDeletable {
    struct Keys {
        static let email = "email"
        static let name = "name"
        static let password = "password"
    }

    public let storage = Storage()

    public private(set) var email: String
    public private(set) var name: String?
    public private(set) var password: String

    /// Initializes the User with name, email and password (plain).
    ///
    /// - Parameters:
    ///   - name: name of the user
    ///   - email: email of the user
    ///   - password: <PASSWORD> (plain)
    public init(
        email: Valid<UniqueEmail>,
        name: Valid<Name>?,
        password: <PASSWORD>
    ) {
        self.email = email.value
        self.name = name?.value
        self.password = <PASSWORD>
    }

    /// Initializer for RowInitializable
    public init(row: Row) throws {
        name = try row.get(Keys.name)
        email = try row.get(Keys.email)
        password = try row.get(Keys.password)
    }

    /// Updates the User with name, email and password. Only updates non-nil parameters.
    ///
    /// - Parameters:
    ///   - name: name of the user
    ///   - email: email of the user
    ///   - password: <PASSWORD>
    func update(
        email: Valid<UniqueEmail>?,
        name: Valid<Name>?,
        password: <PASSWORD>?
    ) {
        if let email = email {
            self.email = email.value
        }

        if let name = name {
            self.name = name.value
        }

        if let password = password {
            self.password = password.value
        }
    }
}

// MARK: - RowRepresentable
extension User {
    public func makeRow() throws -> Row {
        var row = Row()
        try row.set(Keys.email, email)
        try row.set(Keys.name, name)
        try row.set(Keys.password, password)
        return row
    }
}

// MARK: - Preparation
extension User: Preparation {
    public static func prepare(_ database: Database) throws {
        try database.create(self) { user in
            user.id()
            user.string(Keys.email)
            user.string(Keys.name)
            user.string(Keys.password)<commit_msg>Make name optional<commit_after>import Authentication
import FluentProvider
import JWT
import JWTProvider
import SMTP

/// Defines basic user that can be authorized.
public final class User: Model, Timestampable, SoftDeletable {
    struct Keys {
        static let email = "email"
        static let name = "name"
        static let password = "password"
    }

    public let storage = Storage()

    public private(set) var email: String
    public private(set) var name: String?
    public private(set) var password: String

    /// Initializes the User with name, email and password (plain).
    ///
    /// - Parameters:
    ///   - name: name of the user
    ///   - email: email of the user
    ///   - password: <PASSWORD> (<PASSWORD>)
    public init(
        email: Valid<UniqueEmail>,
        name: Valid<Name>?,
        password: <PASSWORD>
    ) {
        self.email = email.value
        self.name = name?.value
        self.password = <PASSWORD>
    }

    /// Initializer for RowInitializable
    public init(row: Row) throws {
        name = try row.get(Keys.name)
        email = try row.get(Keys.email)
        password = try row.get(Keys.password)
    }

    /// Updates the User with name, email and password. Only updates non-nil parameters.
    ///
    /// - Parameters:
    ///   - name: name of the user
    ///   - email: email of the user
    ///   - password: <PASSWORD>
    func update(
        email: Valid<UniqueEmail>?,
        name: Valid<Name>?,
        password: <PASSWORD>?
    ) {
        if let email = email {
            self.email = email.value
        }

        if let name = name {
            self.name = name.value
        }

        if let password = password {
            self.password = <PASSWORD>
        }
    }
}

// MARK: - RowRepresentable
extension User {
    public func makeRow() throws -> Row {
        var row = Row()
        try row.set(Keys.email, email)
        try row.set(Keys.name, name)
        try row.set(Keys.password, password)
        return row
    }
}

// MARK: - Preparation
extension User: Preparation {
    public static func prepare(_ database: Database) throws {
        try database.create(self) { user in
            user.id()
            user.string(Keys.email)
            user.string(Keys.name, optional: true)
            user.string(Keys.password)
{'fraction_non_alphanumeric': 0.10740421868273783, 'fraction_numerical': 0.0, 'mean_word_length': 1.8720642768850433, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '3943189', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1291, 'n_words': 411}