token-validator: ip, ping, ...
This commit is contained in:
parent
6d6af5f7f4
commit
081b22a64a
5 changed files with 118 additions and 28 deletions
|
|
@ -87,7 +87,7 @@ func getStudent(id int) (s Student, err error) {
|
|||
}
|
||||
|
||||
func getStudentByLogin(login string) (s Student, err error) {
|
||||
err = DBQueryRow("SELECT id_student, login, time FROM students WHERE login=?", login).Scan(&s.Id, &s.Login, &s.Time)
|
||||
err = DBQueryRow("SELECT S.id_student, S.login, MAX(L.time), L.ip, L.mac FROM students S INNER JOIN (SELECT a.id_student, a.time, a.ip, a.mac FROM student_login a INNER JOIN (SELECT id_student, MAX(time) AS time FROM student_login GROUP BY id_student) b ON a.id_student = b.id_student AND a.time = b.time) L ON S.id_student = L.id_student WHERE login=?", login).Scan(&s.Id, &s.Login, &s.Time, &s.IP, &s.MAC)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -155,6 +155,9 @@ func createStudent(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
exist.registerAccess(std.IP, std.MAC)
|
||||
|
||||
exist.IP = fmt.Sprintf("172.23.0.%d", exist.IPSuffix())
|
||||
|
||||
return exist, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue