     }
 
     public init(row: Row) throws {
-        self.id = try row.get("id")
         self.name = try row.get("name")
         self.email = try row.get("email")
         self.password = try row.get("password")

import Authentication
import FluentProvider
import Foundation
import JWT
import Sugar
import Vapor


extension User: UserClaimRepresentable {
    public func makeUserClaim() throws -> UserClaim {
        return UserClaim(try Node(node: [
            "id": self.id ?? "",
            ]))
    }
}

extension User: Storable {
    public static let name = "user"

    public var node: Node {
        return id?.makeNode(in: nil) ?? ""
    }
}

public struct UserIdentifier: JSONInitializable {
    let id: Identifier

    public init(json: JSON) throws {
        id = Identifier(try json.get(User.name) as Node)
    }
}

extension User: PayloadAuthenticatable {
    public typealias PayloadType = UserIdentifier

    public static func authenticate(_ payload: PayloadType) throws -> User {
        guard let user = try User.find(payload.id) else {
            throw Abort.init(.badRequest, reason: "User not found")
        }

        return user
    }
}
