Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(50)

Side by Side Diff: state/apiserver/common/password.go

Issue 61620043: Started working on add/remove user support
Patch Set: Started working on add/remove user support Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « state/apiserver/client/api_test.go ('k') | state/apiserver/common/password_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package common 4 package common
5 5
6 import ( 6 import (
7 "launchpad.net/juju-core/log" 7 "launchpad.net/juju-core/log"
8 "launchpad.net/juju-core/state" 8 "launchpad.net/juju-core/state"
9 "launchpad.net/juju-core/state/api/params" 9 "launchpad.net/juju-core/state/api/params"
10 ) 10 )
11 11
12 // PasswordChanger implements a common SetPasswords method for use by 12 // PasswordChanger implements a common SetPasswords method for use by
13 // various facades. 13 // various facades.
14 type PasswordChanger struct { 14 type PasswordChanger struct {
15 st state.EntityFinder 15 st state.EntityFinder
16 getCanChange GetAuthFunc 16 getCanChange GetAuthFunc
17 } 17 }
18 18
19 // NewPasswordChanger returns a new PasswordChanger. The GetAuthFunc will be 19 // NewPasswordChanger returns a new PasswordChanger. The GetAuthFunc will be
20 // used on each invocation of SetPasswords to determine current permissions. 20 // used on each invocation of SetPasswords to determine current permissions.
21 func NewPasswordChanger(st state.EntityFinder, getCanChange GetAuthFunc) *Passwo rdChanger { 21 func NewPasswordChanger(st state.EntityFinder, getCanChange GetAuthFunc) *Passwo rdChanger {
22 return &PasswordChanger{ 22 return &PasswordChanger{
23 st: st, 23 st: st,
24 getCanChange: getCanChange, 24 getCanChange: getCanChange,
25 } 25 }
26 } 26 }
27 27
28 // SetPasswords sets the given password for each supplied entity, if possible. 28 // SetPasswords sets the given password for each supplied entity, if possible.
29 func (pc *PasswordChanger) SetPasswords(args params.PasswordChanges) (params.Err orResults, error) { 29 func (pc *PasswordChanger) SetPasswords(args params.EntityPasswords) (params.Err orResults, error) {
30 result := params.ErrorResults{ 30 result := params.ErrorResults{
31 Results: make([]params.ErrorResult, len(args.Changes)), 31 Results: make([]params.ErrorResult, len(args.Changes)),
32 } 32 }
33 if len(args.Changes) == 0 { 33 if len(args.Changes) == 0 {
34 return result, nil 34 return result, nil
35 } 35 }
36 canChange, err := pc.getCanChange() 36 canChange, err := pc.getCanChange()
37 if err != nil { 37 if err != nil {
38 return params.ErrorResults{}, err 38 return params.ErrorResults{}, err
39 } 39 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 break 88 break
89 } 89 }
90 } 90 }
91 } 91 }
92 if err == nil { 92 if err == nil {
93 err = entity.SetPassword(password) 93 err = entity.SetPassword(password)
94 log.Infof("setting password for %q", tag) 94 log.Infof("setting password for %q", tag)
95 } 95 }
96 return err 96 return err
97 } 97 }
OLDNEW
« no previous file with comments | « state/apiserver/client/api_test.go ('k') | state/apiserver/common/password_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b