Create DB function to update a player's password
This commit is contained in:
parent
003b56f6a0
commit
5871943455
28
wmud/db.c
28
wmud/db.c
@ -183,6 +183,34 @@ wmud_db_save_player(WmudPlayer *player, GError **err)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
wmud_db_update_player_password(WmudPlayer *player, gchar *crypted_password, GError **err)
|
||||
{
|
||||
GValue *cpw,
|
||||
player_id = G_VALUE_INIT;
|
||||
GError *local_err = NULL;
|
||||
|
||||
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Saving player password for %s", wmud_player_get_player_name(player));
|
||||
|
||||
if (dbh == NULL) {
|
||||
g_set_error(err, WMUD_DB_ERROR, WMUD_DB_ERROR_NOINIT, "Database backend not initialized");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_value_init(&player_id, G_TYPE_UINT);
|
||||
g_value_set_uint(&player_id, wmud_player_get_id(player));
|
||||
cpw = gda_value_new_from_string(crypted_password, G_TYPE_STRING);
|
||||
|
||||
if (!gda_connection_update_row_in_table(dbh, "players", "id", &player_id, &local_err, "password", cpw)) {
|
||||
g_set_error(err, WMUD_DB_ERROR, WMUD_DB_ERROR_BADQUERY, "Error saving player password: %s", local_err->message);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
wmud_db_load_planes(GSList **planes, GError **err)
|
||||
{
|
||||
|
@ -52,6 +52,7 @@ gboolean wmud_db_load_rooms(GSList **rooms, GError **err);
|
||||
gboolean wmud_db_load_exits(GSList **exits, GError **err);
|
||||
gboolean wmud_db_load_planet_planes(GSList **planet_planes, GError **err);
|
||||
gboolean wmud_db_load_menu(GSList **menu_items, GError **err);
|
||||
gboolean wmud_db_update_player_password(WmudPlayer *player, gchar *crypted_password, GError **err);
|
||||
|
||||
#endif /* __WMUD__DB_H__ */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user