Improve ping,logout commands.
This commit is contained in:
parent
c7fb0d0ed5
commit
3f6b714506
10
commands.go
10
commands.go
|
@ -283,6 +283,11 @@ func (handler *CommandHandler) CommandLogout(ce *CommandEvent) {
|
||||||
} else {
|
} else {
|
||||||
leavePortals(ce)
|
leavePortals(ce)
|
||||||
}
|
}
|
||||||
|
var pass string;
|
||||||
|
ret := ce.User.bridge.DB.User.GetPassByMXID(ce.User.MXID, &pass)
|
||||||
|
if ret && pass != "" {
|
||||||
|
ce.Reply("WARNING, your password is stored in database. Use command `remove-password` to remove it.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmdSavePasswordHelp = `save-password - save user password into database`
|
const cmdSavePasswordHelp = `save-password - save user password into database`
|
||||||
|
@ -383,6 +388,11 @@ func (handler *CommandHandler) CommandPing(ce *CommandEvent) {
|
||||||
}
|
}
|
||||||
ce.Reply("You're logged in as @" + username + ", orgid is " + orgId)
|
ce.Reply("You're logged in as @" + username + ", orgid is " + orgId)
|
||||||
}
|
}
|
||||||
|
var pass string;
|
||||||
|
ret := ce.User.bridge.DB.User.GetPassByMXID(ce.User.MXID, &pass)
|
||||||
|
if ret && pass != "" {
|
||||||
|
ce.Reply("WARNING, your password is stored in database. Use command `remove-password` to remove it.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cmdHelpHelp = `help - Prints this help`
|
const cmdHelpHelp = `help - Prints this help`
|
||||||
|
|
|
@ -54,6 +54,15 @@ func (uq *UserQuery) GetByJID(userID types.SkypeID) *User {
|
||||||
return uq.New().Scan(row)
|
return uq.New().Scan(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (uq *UserQuery) GetPassByMXID(userID id.UserID, password *string) bool {
|
||||||
|
row := uq.db.QueryRow(`SELECT password FROM "user" WHERE mxid=$1`, userID)
|
||||||
|
if row == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
err := row.Scan(password)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
func (uq *UserQuery) SetPassByMXID(password string, userID id.UserID) bool {
|
func (uq *UserQuery) SetPassByMXID(password string, userID id.UserID) bool {
|
||||||
row := uq.db.QueryRow(`UPDATE "user" SET password=$1 WHERE mxid=$2`, password, userID)
|
row := uq.db.QueryRow(`UPDATE "user" SET password=$1 WHERE mxid=$2`, password, userID)
|
||||||
return row != nil
|
return row != nil
|
||||||
|
|
2
user.go
2
user.go
|
@ -396,7 +396,7 @@ func (user *User) monitorSession(ce *CommandEvent) {
|
||||||
if x > 0 {
|
if x > 0 {
|
||||||
user.SetSession(user.Conn.LoginInfo)
|
user.SetSession(user.Conn.LoginInfo)
|
||||||
} else {
|
} else {
|
||||||
ce.Reply("Session expired")
|
ce.Reply("Session expired\nStore your password into database with command `save-password` to resolve this issue.")
|
||||||
close(user.Conn.Refresh)
|
close(user.Conn.Refresh)
|
||||||
leavePortals(ce)
|
leavePortals(ce)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue