gaccount: AccountName,
nick: Option<String>,
timezone: Option<String>,
+ // xxx default to UrlOnStdout
+ // xxx options for others
access: Option<Box<dyn PlayerAccessSpec>>,
socket_path: String,
verbose: i32,
Fine
},
- CreateAccont(AccountDetails { account, nick, timezone, access }) => {
+ CreateAccount(AccountDetails { account, nick, timezone, access }) => {
let mut ag = AccountsGuard::lock();
let auth = authorise_for_account(cs, &ag, &account)?;
let access = cs.accountrecord_from_spec(access)?
Fine
}
- UpdateAccont(AccountDetails { account, nick, timezone, access }) => {
+ UpdateAccount(AccountDetails { account, nick, timezone, access }) => {
let mut ag = AccountsGuard::lock();
let mut games = games_lock();
let auth = authorise_for_account(cs, &ag, &account)?;
}
update_from(nick, &mut record.nick );
update_from(timezone, &mut record.timezone);
+/*
+ xxx
+ if let Some(new_timezone) = timezone {
+ let ipr = ig.iplayers.byid_mut(player)?;
+ ipr.ipl.tz = tz_from_str(&new_timezone);
+ }
+*/
Fine
})
?
}
Insn::JoinGame {
- details: MgmtPlayerDetails { timezone, nick }
+ details: MgmtPlayerDetails { nick }
} => {
let account = &cs.current_account()?.notional_account;
- let (_arecord, acctid) = ag.lookup(account)?;
+ let (arecord, acctid) = ag.lookup(account)?;
let (ig, auth) = cs.check_acl(ag, ig, PCH::Instance, &[TP::Play])?;
let nick = nick.ok_or(ME::ParameterMissing)?;
let logentry = LogEntry {
html: Html(format!("{} ({}) joined the game",
&nick, &account)),
};
- let timezone = timezone.as_ref().map(String::as_str)
- .unwrap_or("");
+ let timezone = &arecord.timezone
+/*.as_ref().map(String::as_str)
+ .unwrap_or("");*/
+;
let tz = tz_from_str(&timezone);
let gpl = GPlayerState {
nick: nick.to_string(),
UpdatePlayer {
player,
- details: MgmtPlayerDetails { nick, timezone },
+ details: MgmtPlayerDetails { nick },
} => {
let ig = cs.check_acl_modify_player(ag, ig, player,
&[TP::ModifyOtherPlayer])?.0;
});
gpl.nick = new_nick;
}
- if let Some(new_timezone) = timezone {
- let ipr = ig.iplayers.byid_mut(player)?;
- ipr.ipl.tz = tz_from_str(&new_timezone);
- }
(U{ log,
pcs: vec![],
raw: None},
Noop,
SetSuperuser(bool),
- CreateAccont(AccountDetails),
- UpdateAccont(AccountDetails),
+ CreateAccount(AccountDetails),
+ UpdateAccount(AccountDetails),
DeleteAccount(AccountName),
SelectAccount(AccountName), // success does not mean account exists
}
#[derive(Debug,Clone,Serialize,Deserialize)]
-pub struct AccessTokenReport {
- lines: Vec<String>,
-}
+pub struct AccessTokenInfo { pub url: String }
+
+#[derive(Debug,Clone,Serialize,Deserialize)]
+pub struct AccessTokenReport { pub lines: Vec<String> }
#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct MgmtGameResponseGameInfo {
MgmtError::ServerFailure(format!("ServerFailure {}\n", &e))
}
}
+
+impl AccessTokenInfo {
+ pub fn report(self) -> Vec<String> {
+ vec![
+ "Game access url:".to_string(),
+ self.url,
+ ]
+ }
+}
player: PlayerId,
_auth: Authorisation<AccountName>,
reset: bool)
- -> Option<AccessTokenReport> {
+ -> AccessTokenReport {
let acctid = self.iplayers.byid(player)?.ipl.acctid;
let access = {
let url = format!("{}/{}",
&config().public_url.trim_start_matches("/"),
token.0);
- let report = AccessTokenReport { url };
- let report = access
- .server_deliver(&gpl, &ipl, &report)?;
- report.cloned()
+ let info = AccessTokenInfo { url };
+ let report = access.deliver(&gpl, &ipl, info)?;
+ report
}
#[throws(MgmtError)]
accounts: &mut AccountsGuard,
player: PlayerId,
auth: Authorisation<AccountName>)
- -> Option<AccessTokenReport> {
+ -> AccessTokenReport {
self.player_access_reset_redeliver(accounts, player, auth, true)?
}
accounts: &mut AccountsGuard,
player: PlayerId,
auth: Authorisation<AccountName>)
- -> Option<AccessTokenReport> {
+ -> AccessTokenReport {
self.player_access_reset_redeliver(accounts, player, auth, false)?
}
#[throws(MgmtError)]
fn check_spec_permission(&self, _: Option<AuthorisationSuperuser>) {
}
- fn server_deliver<'t>(&self,
- _gpl: &GPlayerState,
- _ipl: &IPlayerState,
- _token: &'t AccessTokenReport)
- -> Result<Option<&'t AccessTokenReport>, TDE> {
- Ok(None)
- }
- fn client_deliver(&self,
- _pi: &MgmtPlayerInfo,
- _token: &AccessTokenReport)
- -> Result<(), TDE> {
- panic!()
- }
+ fn deliver(&self,
+ gpl: &GPlayerState,
+ ipl: &IPlayerState,
+ token: AccessTokenInfo)
+ -> Result<AccessTokenReport, TDE>;
fn describe_html(&self) -> Html {
let inner = Html::from_txt(&format!("{:?}", self));
Html(format!("<code>{}</code>", inner.0))
#[typetag::serde]
impl PlayerAccessSpec for PlayerAccessUnset {
+ #[throws(TokenDeliveryError)]
+ fn deliver(&self,
+ _gpl: &GPlayerState,
+ _ipl: &IPlayerState,
+ _token: AccessTokenInfo) -> AccessTokenReport {
+ AccessTokenReport { lines: vec![
+ "Player access not set, game not accessible to this player"
+ .to_string(),
+ ] }
+ }
}
#[typetag::serde]
fn override_token(&self) -> Option<&RawToken> {
Some(&self.token)
}
+ #[throws(TokenDeliveryError)]
+ fn deliver(&self,
+ _gpl: &GPlayerState,
+ _ipl: &IPlayerState,
+ _token: AccessTokenInfo) -> AccessTokenReport {
+ AccessTokenReport { lines: vec![ "Fixed access token".to_string() ] }
+ }
}
#[typetag::serde]
impl PlayerAccessSpec for UrlOnStdout {
#[throws(TDE)]
- fn server_deliver<'t>(&self,
- _gpl: &GPlayerState,
- _ipl: &IPlayerState,
- token: &'t AccessTokenReport)
- -> Option<&'t AccessTokenReport> {
- Some(token)
- }
- #[throws(TDE)]
- fn client_deliver(&self,
- pi: &MgmtPlayerInfo,
- token: &AccessTokenReport) {
- println!("access account={} nick={:?} url:\n{}",
- &pi.account, &pi.nick, token.url);
+ fn deliver<'t>(&self,
+ _gpl: &GPlayerState,
+ _ipl: &IPlayerState,
+ token: AccessTokenInfo)
+ -> AccessTokenReport {
+ AccessTokenReport { lines: token.report() }
}
}