[O] Limit exposure of fields

pull/14/head
Azalea 2024-02-20 16:16:11 -05:00
parent 878a543818
commit 4b8385419e
3 changed files with 8 additions and 13 deletions

View File

@ -133,19 +133,7 @@ class UserRegistrar(
} }
@API("/me") @API("/me")
suspend fun getUser(@RP token: Str) = jwt.auth(token) { u -> suspend fun getUser(@RP token: Str) = jwt.auth(token)
mapOf(
"username" to u.username,
"email" to u.email,
"lastLogin" to u.lastLogin,
"regTime" to u.regTime,
"profileLocation" to u.profileLocation,
"profileBio" to u.profileBio,
"emailConfirmed" to u.emailConfirmed,
"ghostCard" to u.ghostCard.luid,
"cards" to u.cards.map { it.luid },
)
}
@API("/setting") @API("/setting")
suspend fun setting(@RP token: Str, @RP key: Str, @RP value: Str) = jwt.auth(token) { u -> suspend fun setting(@RP token: Str, @RP key: Str, @RP value: Str) = jwt.auth(token) { u ->

View File

@ -1,5 +1,6 @@
package icu.samnyan.aqua.net.db package icu.samnyan.aqua.net.db
import com.fasterxml.jackson.annotation.JsonIgnore
import ext.Str import ext.Str
import ext.isValidEmail import ext.isValidEmail
import ext.minus import ext.minus
@ -17,6 +18,7 @@ import kotlin.reflect.full.functions
@Entity(name = "AquaNetUser") @Entity(name = "AquaNetUser")
@Table(name = "aqua_net_user") @Table(name = "aqua_net_user")
class AquaNetUser( class AquaNetUser(
@JsonIgnore
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
var auId: Long = 0, var auId: Long = 0,
@ -26,6 +28,8 @@ class AquaNetUser(
// Login credentials // Login credentials
@Column(nullable = false, unique = true) @Column(nullable = false, unique = true)
var email: String = "", var email: String = "",
@JsonIgnore
@Column(nullable = false) @Column(nullable = false)
var pwHash: String = "", var pwHash: String = "",

View File

@ -1,5 +1,6 @@
package icu.samnyan.aqua.sega.general.model; package icu.samnyan.aqua.sega.general.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import icu.samnyan.aqua.net.db.AquaNetUser; import icu.samnyan.aqua.net.db.AquaNetUser;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -29,6 +30,7 @@ public class Card implements Serializable {
// A external id // A external id
@Column(name = "ext_id", unique = true) @Column(name = "ext_id", unique = true)
@JsonIgnore // Sensitive information
private Long extId; private Long extId;
// Access Code // Access Code
@ -44,5 +46,6 @@ public class Card implements Serializable {
// Defines the AquaNet user that this card is bound to // Defines the AquaNet user that this card is bound to
@ManyToOne @ManyToOne
@JoinColumn(name = "net_user_id") @JoinColumn(name = "net_user_id")
@JsonIgnore
private AquaNetUser aquaUser; private AquaNetUser aquaUser;
} }