Proyectos de Subversion LeadersLinked - Services

Rev

Rev 258 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 258 Rev 265
Línea 10... Línea 10...
10
use LeadersLinked\Model\User;
10
use LeadersLinked\Model\User;
Línea 11... Línea 11...
11
 
11
 
12
 
12
 
-
 
13
class ExternalCredentials
13
class ExternalCredentials
14
{
14
{
15
    
15
    /**
16
    /**
16
     * 
17
     * 
17
     * @var ExternalCredentials
18
     * @var ExternalCredentials
Línea 41... Línea 42...
41
     * 
42
     * 
42
     * @var string
43
     * @var string
43
     */
44
     */
44
    private $password_xmpp;
45
    private $password_xmpp;
Línea -... Línea 46...
-
 
46
    
-
 
47
    
-
 
48
    /**
-
 
49
     * 
-
 
50
     * @var string
-
 
51
     */
-
 
52
    private $username_inmail;
-
 
53
    
-
 
54
    /**
-
 
55
     * 
-
 
56
     * @var string
-
 
57
     */
-
 
58
    private $password_inmail;
Línea 45... Línea 59...
45
    
59
    
46
 
60
 
47
    
61
    
Línea 123... Línea 137...
123
    {
137
    {
124
        $user->username_xmpp = $this->username_xmpp = $this->checkAndGetUsername($user->first_name, $user->last_name);
138
        $user->username_xmpp = $this->username_xmpp = $this->checkAndGetUsername($user->first_name, $user->last_name);
125
        $this->password_xmpp  = Functions::generatePassword(32);
139
        $this->password_xmpp  = Functions::generatePassword(32);
Línea -... Línea 140...
-
 
140
        
-
 
141
        
-
 
142
        $networkMapper = \LeadersLinked\Mapper\NetworkMapper::getInstance($this->adapter);
-
 
143
        $network =  $networkMapper->fetchOne($user->network_id);
-
 
144
        
-
 
145
        
-
 
146
        $user->username_inmail = $this->username_inmail = $user->username_xmpp . '@' . $network->inmail_domain;
-
 
147
 
-
 
148
        $salt = Functions::generatePassword(16);
-
 
149
        $this->password_inmail  = Functions::generatePassword(32);
-
 
150
                
-
 
151
      
126
        
152
        
127
        
153
        
-
 
154
        $user->external_credentials = [
128
        $user->external_credentials = [
155
            'password_xmpp' =>  $this->password_xmpp,
Línea 129... Línea -...
129
            'password_xmpp' =>  $this->password_xmpp
-
 
-
 
156
            'password_inmail' => $this->password_inmail
130
        ];
157
        ];
131
        
158
        
Línea 132... Línea 159...
132
        
159
        $user->password_inmail = crypt($this->password_inmail, '$6$' . $salt);
133
        $user->password_xmpp = sha1( $this->password_xmpp);
160
        $user->password_xmpp = md5( $this->password_xmpp);
134
    }
161
    }
135
    
162
    
136
    /**
163
    /**
137
     * 
164
     * 
138
     * @param int $id
165
     * @param int $id
139
     */
166
     */
-
 
167
    public function getUserBy($id)
-
 
168
    {
Línea 140... Línea 169...
140
    public function getUserBy($id)
169
        $this->username_xmpp = '';
141
    {
170
        $this->password_xmpp = '';
142
        $this->username_xmpp = '';
171
        $this->username_inmail = '';
Línea 143... Línea 172...
143
        $this->password_xmpp = '';
172
        $this->password_inmail = '';
144
        
173
        
145
        
174
        
Línea -... Línea 175...
-
 
175
        $userMapper = UserMapper::getInstance($this->adapter);
-
 
176
        $user = $userMapper->fetchOne($id);
-
 
177
        if($user) {
146
        $userMapper = UserMapper::getInstance($this->adapter);
178
            
Línea 147... Línea 179...
147
        $user = $userMapper->fetchOne($id);
179
            if($user->status == User::STATUS_DELETED) {
Línea 148... Línea 180...
148
        if($user) {
180
                return;
Línea 170... Línea 202...
170
            
202
            
171
            if(!empty($external_credentials['password_xmpp'])) {
203
            if(!empty($external_credentials['password_xmpp'])) {
172
                $this->password_xmpp = $external_credentials['password_xmpp'];
204
                $this->password_xmpp = $external_credentials['password_xmpp'];
Línea -... Línea 205...
-
 
205
            }
-
 
206
            
-
 
207
            if(!empty($external_credentials['password_inmail'])) {
-
 
208
                $this->password_inmail = $external_credentials['password_inmail'];
Línea 173... Línea 209...
173
            }
209
            }
174
            
210
            
175
            
211
            
Línea 176... Línea 212...
176
            if(!$user->username_xmpp || is_numeric($user->username_xmpp)) {
212
            if(!$user->username_xmpp || is_numeric($user->username_xmpp)) {
Línea -... Línea 213...
-
 
213
                $user->username_xmpp = $this->username_xmpp = $this->checkAndGetUsername($user->first_name, $user->last_name);
-
 
214
                $needSave = true;
-
 
215
                
-
 
216
            }
-
 
217
            
-
 
218
            if(!$user->username_inmail || is_numeric($user->username_inmail)) {
-
 
219
                
-
 
220
                if(!is_numeric($user->username_xmpp)) {
177
                $user->username_xmpp = $this->username_xmpp = $this->checkAndGetUsername($user->first_name, $user->last_name);
221
                    $user->username_inmail = $user->username_xmpp . '@' . $network->inmail_domain;
-
 
222
                    $needSave = true;
Línea 178... Línea 223...
178
                $needSave = true;
223
                }
179
                
224
            }
Línea 180... Línea 225...
180
            }
225
            
Línea 189... Línea 234...
189
                
234
                
190
                
235
                
Línea -... Línea 236...
-
 
236
                $user->password_xmpp = md5( $this->password_xmpp);
-
 
237
            } 
-
 
238
            
-
 
239
            if(!$user->password_inmail|| !$this->password_inmail) {
-
 
240
                $needSave = true;
-
 
241
                
-
 
242
                $salt = Functions::generatePassword(16);
-
 
243
                
-
 
244
                $this->password_inmail  = Functions::generatePassword(32);
-
 
245
                $external_credentials['password_inmail'] =  $this->password_inmail;
-
 
246
                
-
 
247
                
Línea 191... Línea 248...
191
                $user->password_xmpp = md5( $this->password_xmpp);
248
                $user->password_inmail = crypt($this->password_inmail, '$6$' . $salt);
Línea 192... Línea 249...
192
            } 
249
                
193
            
250
            } 
Línea 221... Línea 278...
221
    public function getPasswordXmpp()
278
    public function getPasswordXmpp()
222
    {
279
    {
223
        return $this->password_xmpp;
280
        return $this->password_xmpp;
224
    }
281
    }
Línea -... Línea 282...
-
 
282
    
-
 
283
    /**
-
 
284
     *
-
 
285
     * @return string
-
 
286
     */
-
 
287
    public function getUsernameInmail()
-
 
288
    {
-
 
289
        return $this->username_inmail;
-
 
290
    }
-
 
291
    
-
 
292
    /**
-
 
293
     *
-
 
294
     * @return string
-
 
295
     */
-
 
296
    public function getPasswordInmail()
-
 
297
    {
-
 
298
        return $this->password_inmail;
-
 
299
    }
-
 
300
    
-
 
301
    
225
    
302
    
226
}
303
}