working commit
This commit is contained in:
+24
-16
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
||||
*
|
||||
* This work is published and licensed under a Creative Commons
|
||||
* Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
||||
*
|
||||
* Distribution of this work is permitted, but commercial use and
|
||||
* modifications are strictly prohibited.
|
||||
*/
|
||||
package handler
|
||||
|
||||
import (
|
||||
@@ -52,16 +61,19 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, string, error) {
|
||||
if err != nil {
|
||||
return success, accountID, err
|
||||
}
|
||||
success, id, err := hand.ValidatePassword(rctx.Ctx, username, password)
|
||||
if err != nil {
|
||||
return false, accountID, err
|
||||
}
|
||||
if !success {
|
||||
err = fmt.Errorf("Incorrect username or password")
|
||||
return false, accountID, err
|
||||
}
|
||||
accountID = id
|
||||
return success, accountID, err
|
||||
}
|
||||
success, id, err := hand.ValidatePassword(rctx.Ctx, username, password)
|
||||
if err != nil {
|
||||
return false, accountID, err
|
||||
}
|
||||
if !success {
|
||||
err = fmt.Errorf("Incorrect username or password")
|
||||
return false, accountID, err
|
||||
}
|
||||
accountID = id
|
||||
success = true
|
||||
accountID = descr.AnonymousID
|
||||
return success, accountID, err
|
||||
}
|
||||
|
||||
@@ -90,16 +102,12 @@ func (hand *Handler) CheckRight(ctx context.Context, accountID, right, subject s
|
||||
var res bool
|
||||
hand.logg.Debugf("Cop check your right %s: %s %s", accountID, right, subject)
|
||||
// =[]=
|
||||
// /------\
|
||||
// .------.
|
||||
// .---[-] [#] \--,
|
||||
// >| [ ] [ ] |
|
||||
// '--0-------0----'
|
||||
// Bad news for you, baby.... #
|
||||
|
||||
// TODO: defer logger
|
||||
|
||||
defer hand.logg.Debugf("Checking right %s for %s: %v", right, accountID, res)
|
||||
|
||||
//
|
||||
exists, grant, err := hand.mdb.GetGrantByAccoundIDRight(ctx, accountID, right)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -107,7 +115,6 @@ func (hand *Handler) CheckRight(ctx context.Context, accountID, right, subject s
|
||||
if !exists {
|
||||
return res, err
|
||||
}
|
||||
|
||||
switch right {
|
||||
case descr.RightReadFiles, descr.RightWriteFiles:
|
||||
grant.Pattern = ".*"
|
||||
@@ -122,5 +129,6 @@ func (hand *Handler) CheckRight(ctx context.Context, accountID, right, subject s
|
||||
// NOP
|
||||
}
|
||||
res = true
|
||||
hand.logg.Debugf("Checking right %s for %s: %v", right, accountID, res)
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user